In my experience, this is not so simple. The built-in PHP SOAP client did not work with the .NET SOAP server that we had to use. He complained about the wrong definition of the scheme. Although the .NET client worked with this server just fine. By the way, let me say that SOAP compatibility is a myth.
The next step was NuSOAP . This has worked for quite some time. By the way, for God's sake, don't forget to cache WSDL! But even with the help of cached users, WSDL complained that it was pretty darn slow.
Then we decided to deal with HTTP, collect the requests and read the answers using SimpleXMLElemnt , for example:
$request_info = array(); $full_response = @http_post_data( 'http://example.com/OTA_WS.asmx', $REQUEST_BODY, array( 'headers' => array( 'Content-Type' => 'text/xml; charset=UTF-8', 'SOAPAction' => 'HotelAvail', ), 'timeout' => 60, ), $request_info ); $response_xml = new SimpleXMLElement(strstr($full_response, '<?xml')); foreach ($response_xml->xpath('//@HotelName') as $HotelName) { echo strval($HotelName) . "\n"; }
Note that in PHP 5.2 you will need pecl_http, since (surprise-surprise!) There is no HTTP client.
Switching to bare HTTP helped us get over 30% of SOAP requests. And from now on, we redirect all performance complaints to the server guys.
In the end, I would recommend this latter approach, and not because of performance. I think that in general, in a dynamic language such as PHP, there is no benefit from all this WSDL / type-control. You don't need a fantastic library for reading and writing XML, with all this stub creation and dynamic proxies. Your language is already dynamic, and SimpleXMLElement works just fine and is so easy to use. In addition, you will have less code, which is always good.
Ivan Krechetov Jan 14 '10 at 10:46
source share