$client = new SoapClient("http://example.com/soap/wsdl"); $result = $client->__soapCall("getUserDetails", array("userId" => 1234)); print_r($result);
$client = new SoapClient("http://example.com/soap/wsdl", array("trace" => 1)); $result = $client->__soapCall("addNumbers", array("num1" => 5, "num2" => 10)); echo "Request:\n" . $client->__getLastRequest() . "\n"; echo "Response:\n" . $client->__getLastResponse() . "\n"; print_r($result);In this example, we pass an additional "trace" option to the SoapClient constructor to enable tracing. We then use the __soapCall method to invoke the "addNumbers" SOAP method with two parameters, "num1" and "num2" set to 5 and 10 respectively. We use the __getLastRequest and __getLastResponse methods to print out the SOAP request and response for debugging purposes. This functionality is part of the PHP standard library.