Creating a Web Service with NuSOAP

At, 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)

  require_once 'nusoap.php';

  $soap = new soap_server;

  function add($a, $b) {
    return $a + $b;


As of this writing, NuSOAP only works under PHP 4, but a PHP 5 port is rumored to be under way.

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:

  • Write the function you want to expose as a web method.
  • Instantiate the soap_server class.
  • Register your function with the SOAP serve.
  • Call the service() method and submit $HTTP_RAW_POST_DATA as the parameter.

2 thoughts on “Creating a Web Service with NuSOAP

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s