How to make PHP Web Service with NuSoap

While investigating how to create a Web Service in PHP I run into NuSoap library, that can generate WSDL based on some matadata describing Web Service method signatures and the data structures. I downloaded NuSoap library and found some trivial sample that started working after adding the highlighted line of code:

function ProcessSimpleType($who) {
    return "Hello $who";

$namespace = "";
// create a new soap server
$server = new soap_server();
$server->soap_defencoding = 'UTF-8'; 
// configure our WSDL
// set our namespace
$server->wsdl->schemaTargetNamespace = $namespace;
// register our WebMethod
                // method name:
                // parameter list:
                // return value(s):
                // namespace:
                // soapaction: (use default)
                // style: rpc or document
                // use: encoded or literal
                // description: documentation for the method
                'A simple Hello World web method');
// Get our posted data if the service is being consumed
// otherwise leave this data blank.                
                ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

// pass our posted data (or nothing) to the soap service                    

C# client that uses the Web Service wrapper generated by MS Visual Studio 2010 consists of three lines:

ServiceReference1.SimpleServicePortTypeClient client = new ServiceReference1.SimpleServicePortTypeClient();

string s = client.ProcessSimpleType("steve");


1 Response to How to make PHP Web Service with NuSoap

  1. Esther says:

    I was using godaddy dedicated server and that time all my services were working fine. Recently moved to shared hosting server. Now the service which doesn;t have input param is not returning results. So i made change to have input param in that service however in device side that service will be non-input and not returning results. How to achieve in server side or is it possible to set default value. Please help me.

Leave a Reply

Your email address will not be published. Required fields are marked *