Question

I am new at wsdl, nusoap code. I am trying to implement a simple hello world programing using Nousoap. I have implemented sever code in wsdl_hello_server.php,

<?php

require_once('nusoap.php');
  $server = new soap_server();
     $server->register('hello');

function hello($name) {
    return 'Hello, ' . $name;
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?>

and client code saved in file wsdl_hello_client.php,

<?php

require_once('nusoap.php');


$client = new soapclient('http://localhost:8888/nousoap_example/wsdl_hello_server.php');



$result = $client->call('hello', array('name' => 'world'));


print_r($result);
?>

When I run client it won't give any result (blank page).And if I try to run server code it give me,

<SO`AP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Body>
       <SOAP-ENV:Fault>
           <faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode>
            <faultactor xsi:type="xsd:string"/>
                <faultstring xsi:type="xsd:string">method '' not defined in service</faultstring>
                 <detail xsi:type="xsd:string"/>
       </SOAP-ENV:Fault>
      </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>`

Did forget somthing ?? please help me ??

NB: I had included 'nusoap.php' in the same folder

Was it helpful?

Solution

My guess is $HTTP_RAW_POST_DATA is unset; therefor you are sending '' to your $server->service() and '' is not an existing function. Try debugging your $HTTP_RAW_POST_DATA.

Also you can debug client and server by adding:

// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';

As from the page you have probably taken the extremely outdated example from.

OTHER TIPS

You can try add ?wsdl at the end of url like:

$client = new soapclient('http://localhost:8888/nousoap_example/wsdl_hello_server.php?wsdl');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top