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 GetCustomerProf ile Webservice:
[PHP]
<?php
//GetCustomerProf ile
$wsdlURL = "http://www.worldcard.c om.my/MerchantV4/wcservices.asmx ?WSDL";
require_once('n usoap.php');
// set the URL or path to the WSDL document
$wsdl = "http://www.worldcard.c om.my/MerchantV4/wcservices.asmx ?WSDL";
// instantiate the SOAP client object
$soap = new soapclient($wsd l,"wsdl");
$soap->useHTTPPersist entConnection() ;
$parameters['parameters']['AppID'] = "GWCBIZPORT AL";
$parameters['parameters']['UserID'] = "NZN_WEB";
$parameters['parameters']['Password'] = "ABC123";
$parameters['parameters']['CustomerID'] = "0154677957 ";
$result = $soap->call("GetCusto merProfile", $parameters);
if($error = $soap->getError()){ die($error);}
// Not sure about how to read the array results
$collrecord = $result["GetCustomerPro fileResult"];
// this part also not working
foreach ($collrecord["OutputPara ms"] as $record){
echo "<br>Name: ".$record["CustomerNa me"];
echo "<br>Email: ".$record["EmailAddre ss"];
}
echo "<pre>" . print_r($result ) . "</pre>";
?>[/PHP]
Now the Result returned as:
Any help will be highly appreciated. Thanks in Advance
Calling the GetCustomerProf ile Webservice:
[PHP]
<?php
//GetCustomerProf ile
$wsdlURL = "http://www.worldcard.c om.my/MerchantV4/wcservices.asmx ?WSDL";
require_once('n usoap.php');
// set the URL or path to the WSDL document
$wsdl = "http://www.worldcard.c om.my/MerchantV4/wcservices.asmx ?WSDL";
// instantiate the SOAP client object
$soap = new soapclient($wsd l,"wsdl");
$soap->useHTTPPersist entConnection() ;
$parameters['parameters']['AppID'] = "GWCBIZPORT AL";
$parameters['parameters']['UserID'] = "NZN_WEB";
$parameters['parameters']['Password'] = "ABC123";
$parameters['parameters']['CustomerID'] = "0154677957 ";
$result = $soap->call("GetCusto merProfile", $parameters);
if($error = $soap->getError()){ die($error);}
// Not sure about how to read the array results
$collrecord = $result["GetCustomerPro fileResult"];
// this part also not working
foreach ($collrecord["OutputPara ms"] as $record){
echo "<br>Name: ".$record["CustomerNa me"];
echo "<br>Email: ".$record["EmailAddre ss"];
}
echo "<pre>" . print_r($result ) . "</pre>";
?>[/PHP]
Now the Result returned as:
Code:
<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
(
[GetCustomerProfileResult] => Array
(
[OutputParams] => Array
(
[CustomerID] => 154677957
[PreferenceFlags] => Array
(
[PreferenceFlag] => Array
(
[0] => Array
(
[Name] => CB
[Value] => DCX
)
[1] => Array
(
[Name] => EMA
[Value] => Y
)
[2] => Array
(
[Name] => HP
[Value] =>
)
[3] => Array
(
[Name] => LP
[Value] => E
)
[4] => Array
(
[Name] => PIN
[Value] => Y
)
[5] => Array
(
[Name] => SMS
[Value] => Y
)
)
)
[Telephones] => Array
(
[Telephone] => Array
(
[TelDescription] => HOME
[TelNumber] => 12345
[BestNumberFlag] => 1
)
)
[Addresses] => Array
(
[Address] => Array
(
[AddressDescription] => HOME
[Address1] => aaa
[Address2] => bbb
[Address3] => ccc
[City] =>
[State] =>
[Country] => MALAYSIA
[PostCode] =>
[CorrespondenceFlag] => 1
)
)
[CustomerName] => [TESTING] WEIS IA2
[CustomerTitle] => MR
[CustomerTypeCode] => TEST
[Gender] => M
[BusinessEmployer] => 0
[ICPassportNo] => DCX-1001
[ICPassportType] => I
[ICPassportCountry] => MALAYSIA
[CompOverDraftLimit] => 0
[CustEntryDeposit] => 0
[RecordActualFlag] => 0
[NotesComments] => RWB PREPAID DINING CARD ONSITE ISSUANCE
[NotesCommentsBufferSize] => 0
[TelephoneStatus] => 0
[AddressStatus] => 0
[EmailStatus] => 0
[PreferredLanguage] => EN
[EmailAddress] => wsooi@genting.com.my
[CustomerCurrency] => RM
[PrincipalCustomerID] => 0
[DateOfBirth] => 28/12/1975
[ReturnCode] => 0
[ErrorCode] => 0
[ErrorDescription] =>
)
)
)
<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
Comment