473,382 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to Read and use NuSoap Response Array into Variables

Hi Guys, I'm very new to NuSoap. I'm able to call a webservice which actually returned me results.. But I'm having trouble to read the response or I simply don't understand how to read the response.. here is the code i've used to call the service. It returns a kind of big array so i'm so much lost inside it.. I would be grateful if someone help me out on reading the array values into variables so that i can do something depends on the result values.. here is the sample codes..

Calling the GetCustomerProfile Webservice:
[PHP]
<?php
//GetCustomerProfile
$wsdlURL = "http://www.worldcard.com.my/MerchantV4/wcservices.asmx?WSDL";
require_once('nusoap.php');

// set the URL or path to the WSDL document
$wsdl = "http://www.worldcard.com.my/MerchantV4/wcservices.asmx?WSDL";

// instantiate the SOAP client object
$soap = new soapclient($wsdl,"wsdl");

$soap->useHTTPPersistentConnection();

$parameters['parameters']['AppID'] = "GWCBIZPORTAL";
$parameters['parameters']['UserID'] = "NZN_WEB";
$parameters['parameters']['Password'] = "ABC123";
$parameters['parameters']['CustomerID'] = "0154677957";
$result = $soap->call("GetCustomerProfile", $parameters);
if($error = $soap->getError()){ die($error);}

// Not sure about how to read the array results
$collrecord = $result["GetCustomerProfileResult"];

// this part also not working
foreach ($collrecord["OutputParams"] as $record){
echo "<br>Name: ".$record["CustomerName"];
echo "<br>Email: ".$record["EmailAddress"];
}

echo "<pre>" . print_r($result) . "</pre>";
?>[/PHP]

Now the Result returned as:
Expand|Select|Wrap|Line Numbers
  1. <br>Name: 1<br>Email: 1<br>Name: <br>Email: <br>Name: <br>Email: <br>Name: <br>Email: <br>Name: [<br>Email: [<br>Name: M<br>Email: M<br>Name: T<br>Email: T<br>Name: M<br>Email: M<br>Name: 0<br>Email: 0<br>Name: D<br>Email: D<br>Name: I<br>Email: I<br>Name: M<br>Email: M<br>Name: 0<br>Email: 0<br>Name: 0<br>Email: 0<br>Name: 0<br>Email: 0<br>Name: R<br>Email: R<br>Name: 0<br>Email: 0<br>Name: 0<br>Email: 0<br>Name: 0<br>Email: 0<br>Name: 0<br>Email: 0<br>Name: E<br>Email: E<br>Name: w<br>Email: w<br>Name: R<br>Email: R<br>Name: 0<br>Email: 0<br>Name: 2<br>Email: 2<br>Name: 0<br>Email: 0<br>Name: 0<br>Email: 0<br>Name: <br>Email: Array
  2. (
  3.     [GetCustomerProfileResult] => Array
  4.         (
  5.             [OutputParams] => Array
  6.                 (
  7.                     [CustomerID] => 154677957
  8.                     [PreferenceFlags] => Array
  9.                         (
  10.                             [PreferenceFlag] => Array
  11.                                 (
  12.                                     [0] => Array
  13.                                         (
  14.                                             [Name] => CB
  15.                                             [Value] => DCX
  16.                                         )
  17.  
  18.                                     [1] => Array
  19.                                         (
  20.                                             [Name] => EMA
  21.                                             [Value] => Y
  22.                                         )
  23.  
  24.                                     [2] => Array
  25.                                         (
  26.                                             [Name] => HP
  27.                                             [Value] => 
  28.                                         )
  29.  
  30.                                     [3] => Array
  31.                                         (
  32.                                             [Name] => LP
  33.                                             [Value] => E
  34.                                         )
  35.  
  36.                                     [4] => Array
  37.                                         (
  38.                                             [Name] => PIN
  39.                                             [Value] => Y
  40.                                         )
  41.  
  42.                                     [5] => Array
  43.                                         (
  44.                                             [Name] => SMS
  45.                                             [Value] => Y
  46.                                         )
  47.  
  48.                                 )
  49.  
  50.                         )
  51.  
  52.                     [Telephones] => Array
  53.                         (
  54.                             [Telephone] => Array
  55.                                 (
  56.                                     [TelDescription] => HOME
  57.                                     [TelNumber] => 12345
  58.                                     [BestNumberFlag] => 1
  59.                                 )
  60.  
  61.                         )
  62.  
  63.                     [Addresses] => Array
  64.                         (
  65.                             [Address] => Array
  66.                                 (
  67.                                     [AddressDescription] => HOME
  68.                                     [Address1] => aaa
  69.                                     [Address2] => bbb
  70.                                     [Address3] => ccc
  71.                                     [City] => 
  72.                                     [State] => 
  73.                                     [Country] => MALAYSIA
  74.                                     [PostCode] => 
  75.                                     [CorrespondenceFlag] => 1
  76.                                 )
  77.  
  78.                         )
  79.  
  80.                     [CustomerName] => [TESTING] WEIS IA2
  81.                     [CustomerTitle] => MR
  82.                     [CustomerTypeCode] => TEST
  83.                     [Gender] => M
  84.                     [BusinessEmployer] => 0
  85.                     [ICPassportNo] => DCX-1001
  86.                     [ICPassportType] => I
  87.                     [ICPassportCountry] => MALAYSIA
  88.                     [CompOverDraftLimit] => 0
  89.                     [CustEntryDeposit] => 0
  90.                     [RecordActualFlag] => 0
  91.                     [NotesComments] => RWB PREPAID DINING CARD ONSITE ISSUANCE
  92.                     [NotesCommentsBufferSize] => 0
  93.                     [TelephoneStatus] => 0
  94.                     [AddressStatus] => 0
  95.                     [EmailStatus] => 0
  96.                     [PreferredLanguage] => EN
  97.                     [EmailAddress] => wsooi@genting.com.my
  98.                     [CustomerCurrency] => RM
  99.                     [PrincipalCustomerID] => 0
  100.                     [DateOfBirth] => 28/12/1975
  101.                     [ReturnCode] => 0
  102.                     [ErrorCode] => 0
  103.                     [ErrorDescription] => 
  104.                 )
  105.  
  106.         )
  107.  
  108. )
  109. <pre>1</pre>
  • I noticed the $result inside pre printed as 1.
  • Another Issue is it takes a load of time to call the webservice.

Any help will be highly appreciated. Thanks in Advance
Mar 12 '08 #1
1 9937
pbmods
5,821 Expert 4TB
Heya, Neo.

In no particular order:

Expand|Select|Wrap|Line Numbers
  1. echo "<pre>" . print_r($result, true) . "</pre>";
Note the second parameter to print_r().

If it's taking a long time to get results from the webservice, it might just be because your server doesn't have good bandwidth, maybe the server hosting the webservice is running inefficient code... there's lots of possibilities that might just be out of your control.

There are ways around this, depending on how your app is set up. For example, you can cache the result of 'GetCustomerProfile' until the User makes a change to his profile.

Also, you might experiment with queueing up requests in the background. For example, if the User makes a change to his profile, you can run a PHP script in the background to contact the webservice and meanwhile let the User know that it might take a few minutes before his changes are saved.

Anyway, on to your parsing problem. Save the best for last, right?

Nothing about the code is immediately jumping out at me. Try print_r()'ing $collrecord and $record just to make sure you're working with what you think you're working with.
Jun 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Eric Dennison | last post by:
I've been playing around with NuSOAP as a PHP based SOAP server and client. Works great! Now I'm trying to write (using gSOAP) a simple C/C++ based client to test against my simple SOAP server....
2
by: Larry Sankey | last post by:
Hello. I am having what is probably the simplest problem there is with Nusoap. I have to admit I'm new to this stuff, but I have some programming experience and what I'm doing *shouldn't* be hard....
0
by: Ward G | last post by:
Hi, Below is a basic webservice using the NuSOAP class. When I run the code to register the service, I get the nice html page generated by nusoap, offering a link to view the WSDL for my...
2
by: Johnny | last post by:
Searched on google for any info relating to this before posting here but found none. I set up a web service using nusoap on apache php 4.3.8 on windows with error_reporting = E_ALL and had that...
1
by: Sigrid | last post by:
Hi! I'm trying to develop a .net application (xml web service client, using SoapHttpClientProtocol), but i can't get any response from xml web service (php, NuSOAP), server url is:...
0
by: OhWhite | last post by:
Using a PHP 4 and Nusoap I get the following errors when attempting to call a web service I need to login to the main web service and get a session token to be able to access the second web...
7
by: craig.keightley | last post by:
I have access to the following web service but always retreive the same error:- Array ( =soapenv:Server.userException =se.brodit.ws.InvalidUserException =Array ( =webserver
1
by: tietram | last post by:
hi i also have some problem to access web api my api taking arguments as an array but the correct request is not generated my code is like this<?php set_time_limit(3*60); /* * $Id:...
2
by: flydev | last post by:
Hello, I have very little knowledge when it comes to SOAP, but a developer I'm working with says it will make things easier when passing data to/from client software and the mySQL database. Anyhow, I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.