Home  /  Questions  /  Question



60   95.3
Nov 07, 2010


PHP SoapClient example

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




89   96.5
Nov 18, 2010
Hi

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