PHP/Network/SOAP Server
Start soap server
<source lang="html4strict">
<?php if (! extension_loaded ( "soap" )) {
dl ( "php_soap.dll" );
} ini_set ( "soap.wsdl_cache_enabled", "0" ); $server = new SoapServer ( "books.wsdl" ); function doMyBookSearch($bookTitle) {
return array ("bookTitle" => "MyBook", "bookYear" => 2005, "bookAuthor" => "s" );
} $server->AddFunction ( "doMyBookSearch" ); $server->handle (); ?>
</source>
The SOAP Server for the getGuid() Method
<source lang="html4strict">
<?php
ini_set("soap.wsdl_cache_enabled", "Off"); function getGuid($prefix) { return uniqid($prefix); } $soap = new SoapServer("guid.wsdl"); $soap->addFunction("getGuid"); $soap->handle();
?>
</source>
The SOAP Server Returns an Error if No Prefix Is Provided
<source lang="html4strict">
<?php
ini_set("soap.wsdl_cache_enabled", "Off"); function getGuid($prefix) { if (!isset($prefix) || trim($prefix) == "") { throw new SoapFault("Server", "No prefix provided."); } else { return uniqid($prefix); } } $soap = new SoapServer("guid.wsdl"); $soap->addFunction("getGuid"); $soap->handle();
?>
</source>