Federico Cargnelutti

Simple is better than complex. Complex is better than complicated. | @fedecarg

Creating a Web Service with NuSOAP

with 2 comments

At http://dietrich.ganx4.com/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;
  }
?>

NOTE

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.
Advertisement

Written by Federico

March 30, 2007 at 11:20 pm

Posted in PHP

2 Responses

Subscribe to comments with RSS.

  1. Here’s another article: NuSOAP

    Anno

    November 28, 2008 at 2:24 am

  2. Cheers mate

    Federico

    December 4, 2008 at 5:13 pm


Leave a Reply

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

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 43 other followers