phpnusoap

nusoap simple server


Hi i am using this code for nusoap server but when i call the server in web browser it shows message "This service does not provide a Web description" Here is the code

<?
//call library
require_once ('lib/nusoap.php');

//using soap_server to create server object
$server = new soap_server;

//register a function that works on server
$server->register('hello');

// create the function
function hello($name)
{
if(!$name){
return new soap_fault('Client','','Put your name!');
}

$result = "Hello, ".$name;
return $result;
}

// create HTTP listener
$server->service($HTTP_RAW_POST_DATA);

exit();
?>

An help ...


Solution

  • Please change your code to,

    <?php
    //call library
    require_once('nusoap.php');
    $URL       = "www.test.com";
    $namespace = $URL . '?wsdl';
    //using soap_server to create server object
    $server    = new soap_server;
    $server->configureWSDL('hellotesting', $namespace);
    
    //register a function that works on server
    $server->register('hello');
    
    // create the function
    function hello($name)
    {
        if (!$name) {
            return new soap_fault('Client', '', 'Put your name!');
        }
        $result = "Hello, " . $name;
        return $result;
    }
    // create HTTP listener
    $server->service($HTTP_RAW_POST_DATA);
    exit();
    ?>
    

    You didnt Define namespace..

    Please see simple example here :-

    http://patelmilap.wordpress.com/2011/09/01/soap-simple-object-access-protocol/