CHAPTER 20 WEB SERVICES // Always create (Post office web site)
Tuesday, December 11th, 2007CHAPTER 20 WEB SERVICES // Always create a parameter array $params = array(); // Create a new SOAP client $client = new soapclient(”http://localhost/book/20/boxing.php”); // Execute the remote method retrieveBio() $boxer = $client->call(’retrieveBio’, $params); // Parse the returned associative array $name = $boxer[”name”]; $age = $boxer[”age”]; $bio = $boxer[”bio”]; // Output the information echo “$name ($age years)
$bio”; ?> Executing the client results in the following output: Muhammed Ali (61 years)
Ali held the World heavyweight title three times throughout his career. Generating a WSDL Document You ll need to generate a Web Services Definition Language (WSDL) document in order to offer clients the opportunity to call methods via a proxy as was demonstrated in Listing 20-7. Doing so via NuSOAP is surprisingly easy, accomplished with few modifications to the servers demonstrated thus far. Two additional methods must be called to initiate WSDL configuration and specify the WSDL namespace: configureWSDL() and schemaTargetNamespace(), respectively. In addition, because PHP is a loosely typed language, both the input and returned values must be defined using XML Schema, which hints at the datatype requirements. Listing 20-11 is a modified version of Listing 20-7, offering WSDL generation support. Listing 20-11. Generating WSDL configureWSDL(’boxing’, ‘urn:boxing’); // Designate the WSDL namespace $server->wsdl->schemaTargetNamespace = ‘urn:boxing’;
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.