This article follows the three articles Introduction to NuSOAP, Programming with NuSOAP and Programming with NuSOAP Part 2, adding some examples to illustrate how to use NuSOAP combined with WSDL to create and use SOAP web services.
Hello, World Redux
The New Client
Defining New Data Structures
Hello, World Redux
I used the common "Hello, World" instance in Introduction to NuSOAP. In that article, I demonstrated client-side and server-side request and response interactions. Here, I'll extend that instance using WSDL.The WSDL file provides the metadata for the service, and NuSOAP allows the programmer to specify the WSDL created by the service using additional fields and methods of the soap_server class.
The Service's code must do many things in the order in which the correct WSDL is generated. The information of the service is specified by calling the configureWSDL method. The information of each method is also specified by providing additional parameters of the register method. The service code using WSDL is demonstrated in the following example:
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('hellowsdl', 'urn:hellowsdl');
// Register the method to expose
$server->register('hello', // method name