Back to list
Views:   15.9K
Replies:  1

PHP SoapClient example

Would anybody have an example of how to consume the exposed service contracts via PHP ?

Sasa Savic, Nov 07, 2010
Reply 1

If you are using PHP 5.x then the below code may help as a starting point:

 $wsdl = "http://....../ServiceName.svc?wsdl"; 
 $endpoint = "http://...../ServiceName.svc/endpointName"; 
 $client = new SoapClient($wsdl, array('location'=>$endpoint)); 

 $container = new stdClass(); 

 $container->request->PropertyA = 'Test 1'; 
 $container->request->PropertyB = 'Test 2'; 
 $container->request->PropertyC = '05/10/2010'; 

 $response = $client->ServiceMethodA($container); 

request is the name of the parameter expected by the web service/WCF method.

If you have a custom type with references to other custom types you can set those properties as follows:

 $container->request->OtherCustomType->Property1 = 'Test'; 

Hope that helps.

Matt Fothergill, Nov 18, 2010
Hello Kaushal Thanks for this, but tell me one thing which I can do from the singleton that I can do same thing from the static class. Then what is the use of a static class?
Aug 31, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.