This article describes the new SOAP extension for PHP. It is intended for PHP developers who want to write their own Web Services servers, or use SOAP to access existing ones. It assumes some familiarity with Web Services, SOAP, and WSDL (Web Services Description Language).
Here is the same PHP SOAP client, rewritten using that WSDL document. Now we donít need to specify the endpoint URI, namespace, SOAPAction header, encoding style and parameter types. All the information comes from the WSDL file. Example 2 (client2.php)
<?php $client = new SoapClient("http://services.xmethods.net/ soap/urn:xmethods-delayed-quotes.wsdl); print($client->getQuote("ibm")); ? >
Thatís a little easier, isnít it? What are the problems with WSDL? The only argument against using it is that the client has to load the relevant WSDL document from the server before the RPC can be made, and this can take a significant amount of time in a Web environment. In order to speed things up, PHPís ext/soap uses a WSDL caching feature that can be controlled through setting the soap.wsdl_cache_enabled, soap.wsdl_cache_dir and soap.wsdl_cache_ttl configuration directives, either in your php.ini or by using ini_set()(see Example 4) ). By default, WSDL caching is turned on and caches WSDL files for one day. Here is the SOAP section for php.ini with default values. You can paste it into your php.ini. [soap] soap.wsdl_cache_enabled = "1" ; enables or disables WSDL caching feature soap.wsdl_cache_dir = "/tmp" ; sets the directory name where SOAP extension will put cache files soap.wsdl_cache_ttl = "86400" ; (time to live) sets the number of second while cached file will be used ; instead of original one