Page 1 of 1
How to call webservices in PHP
Posted: Fri Feb 13, 2009 8:11 am
by Jan0
Hi,
I need to know how to call WSDL webservice using SOAP in php?Can anyone please send me sample code which is having the details of how to call webservice,how to send our parameters in the request and dealing with response? Looking forward for your reply.Thanks in advance.
Re: How to call webservices in PHP
Posted: Fri Feb 13, 2009 1:21 pm
by Weirdan
Re: How to call webservices in PHP
Posted: Fri Feb 13, 2009 1:47 pm
by sparrrow
I learned everything I know now from the PHP manual.
http://us.php.net/soap
Each web service may operate a little differently than the next, so not all SOAP call functions necessarily will work interchangeably. Here's mine though; it may get you started.
Code: Select all
$wsdl = "samplewebservice.asmx?WSDL";//web service call url
$client = new SoapClient($wsdl);
$params->SessionID = $sessionID;
$params->SampleVar = $sampleVar;
//$params->SampleVar2 = $sampleVar2; //Keep adding as many as necessary
$objectresult = $client->GetWidgets($params);//Send
$simpleresult = $objectresult->GetWidgetsResult;//Receive
print("<b>Raw XML Result: </b><textarea cols=\"100\" disabled>$simpleresult</textarea><br />");
*chuckle*... First time I've seen that.
