Archive for the ‘php’ tag
PHP/.NET Web Services. My Battles
I am working on a project, coding in PHP (a language I am still relatively new in) and I have to consume a web service written in ASP.NET. And yes, I had to provide support in writing the web service, so I know quite a bit about how it works, internally.
My headaches started with consuming the results in PHP. All I got was a response “Array”. Nothing more. New to PHP, it took me a while to figure that I could display the results using the print_r function. Also, I could access some part of the array. Fine.
I am using the NuSOAP library as I learnt that .NET Web Services tend largely to SOAP.
I then noticed that the web service could not read my input. Blast. Long story short, I fund out that I had to wrap the parameters in a parameters array.
require_once('libs/nusoap.php');
/* Initialize parameter */
$PayerID = $_POST['PayerID'];
$param = array('sortOrder'=>$PayerID);
/* create the client for my rpc/encoded web service */
$wsdl = "http://192.168.200.187/PayTesting.asmx?WSDL";
$client = new soapclient($wsdl,true);
$err = $client->getError();
// Let NuSoap extract the correct target namespace from the WSDL!
$result = $client->call('FetchData', array('parameters' =>$param));
I hope this helps someone.