This section describes a tutorial example of a complete SOAP application with both server and client programs using SOAP 1.2 in WSDL mode.
Now let's move forward one step further: creating a SOAP 1.2 server application in WSDL mode.
Here is the same hello server modified to work in WSDL mode, HelloServerWdsl.php:
<?php # HelloServerWsdl.php
# Copyright (c) 2005 by Dr. Herong Yang
#
function hello($someone) {
return "Hello " . $someone . "! - With WSDL";
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("http://localhost/Hello.wsdl",
array('soap_version' => SOAP_1_2));
$server->addFunction("hello");
$server->handle();
?>
Nothing special in the program. The server object is now created with the location of the WSDL document.
The WSDL document looks complicated. But it actually very simple to understand, as long as you remember
the following points:
Read the document backward. The goal of this document is to define a "service" with two pieces of information:
"binding" definition, and "url" where to reach the server. The "binding" is then defined with "type",
"style", "transportation" and "operation". And so on.
The values of "name" attributes in most of the elements are identifiers local to this document only.
You can use any strings. Some of them will be used on the SOAP messages.
The values of "namespace" attributes can also be any strings. They are just used to distinguish name spaces.
To install HelloServerWsdl.php to my IIS server, copy these two files to the IIS document directory:
Anything interesting here? Yes. Some names defined in the WSDL document did show up in the SOAP
request message and response message, like: "urn:myInputNamespace", "reqParam",
"urn:myOutputNamespace", etc.