I’ve read every question on Stackoverflow as well as every Google article I could find.
I need to consume a SOAP API that is being provided by a Microsoft system that uses datasets.
I’ve got to the point where I feel that I need to do this:
$soapClient = new soapclient($this->wsdlUrl,array('trace'=>true));
$soapResult = $soapClient->GetScheduledSectors();
$xmlResult = $soapClient->__getLastResponse();
$xml = simplexml_load_string($xmlResult, NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/");
Rather than using this approach:
$result = $soapClient->GetScheduledSectors();
$xml = simplexml_load_string($result->GetScheduledSectorsResult->any)
Because simplexml cannot parse the result as it lacks the soap response headers.
However, even though the first method does not throw any errors I am left with an empty object like this:
SimpleXMLElement Object
(
[Body] => SimpleXMLElement Object
(
)
)
I really cannot find any coherent example of how to consume a Microsoft SOAP service. I tried reading the MSDN stuff but it’s geared exclusively towards their proprietary libraries so is of little use to anybody else.
There are a few tools I resort to when running into SOAP issues,
SoapUI It’s a great tool that reads the service definition from the WSDL and creates stubbed out signatures for you. You can test hitting the service quickly and check responses & sample payloads when running into issues with your own clients.
TCPMon When the going get’s tough sometimes you have to look at the data going across the wire. Running a request (that works) through SoapUI, then the same payload through a SoapClient PHP program and watching them both in transit can help you isolate issues in the PHP code.
NuSoap When all else fails… NuSoap was pre-SoapClient, but even after SoapClient hit the scenes NuSoap remains useful for edge cases where SoapClient just isn’t cutting it. There are also some functions (eg. Soap Attachements?) NuSoap implements that SoapClient doesn’t have.