How to call webservices in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jan0
Forum Newbie
Posts: 2
Joined: Fri Feb 13, 2009 8:00 am

How to call webservices in PHP

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: How to call webservices in PHP

Post by Weirdan »

sparrrow
Forum Commoner
Posts: 81
Joined: Mon Oct 20, 2008 12:22 pm

Re: How to call webservices in PHP

Post 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. :lol:
Post Reply