Creating a Web Service with NuSOAPAt http://dietrich.ganx4.com/nusoap/and http://sourceforge.net/projects/nusoap/, you will find NuSOAP, one of the best-known SOAP classes for PHP. Some might even know its predecessor, SOAPx4. For some time, releases weren't done very often, but now the project is active again. Nevertheless, you might be better off to check the Concurrent Versions System (CVS) system for the most recent code. Even though you might find several files there, nusoap.php is the one you want. Calling an XML-RPC Web Service (xmlrpc-pear-client.php)<?php require_once 'nusoap.php'; $soap = new soap_server; $soap->register('add'); $soap->service($HTTP_RAW_POST_DATA); function add($a, $b) { return $a + $b; } ?>
Creating a Web Service with NuSOAP is really simple because the module takes care of all the painful things, including SOAP. Just follow these steps:
This code implements a SOAP server using NuSOAP. Figure 9.2 shows the output in the browser when you are trying to call the Web Service directly from the client. The error message says that the XML was emptyof course, because we didn't send a request! Figure 9.2. This error message is a good signthe script seems to work (so far). |