I wanted to learn about SOAP in PHP but I couldn't find any complete examples. This post provides a Hello SOAP client/server implementation and uses a WDSL example from here.


ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer('hello.wsdl');

function doHello($name) {
   return "Hello $name";



ini_set("soap.wsdl_cache_enabled", "0"); 
$client = new SoapClient("http://localhost/hello.wsdl"); 
$my_name = "Chris"; 
$response = $client->doHello( $my_name );
print("SOAP server response: $response");


See here.


I kept noticing:

ini_set("soap.wsdl_cache_enabled", "0");

Make sure you change the SOAP address in your WDSL file to the location of your server. The tag you're looking for is soap:address Here's what I changed mine to:

soap:address location="http://localhost/hello_soap_server.php"

This is my first SOAP experiment so I haven't run into any problems but apparently PHP can cache WDSL files so if one updates the server code and WDSL with new function(s), without this line, the client could fail to see the new function(s) with an older (cached) WDSL file.