Search code examples
phpweb-servicessoapwsdl

SOAP server error in php?


I want to connect two computer by SOAP in non wsdl mode. For testing, I was writing two files , hello_client.php and hello_server.php but it show an error.

"Fatal error: Uncaught SoapFault exception: [Client] DTD are not supported by SOAP in E:\xampp\htdocs\test_server\wsdl\hello_client.php:10 Stack trace: #0 E:\xampp\htdocs\test_server\wsdl\hello_client.php(10): SoapClient->__call('addNumber', Array) #1 E:\xampp\htdocs\test_server\wsdl\hello_client.php(10): SoapClient->addNumber(10, 10) #2 {main} thrown in E:\xampp\htdocs\test_server\wsdl\hello_client.php on line 10"

my code:

// hello_client.php
 $options = array(
'uri' => 'http://host_name/test_server',
'location' => 'http://host_name/test_server/wsdl/hello_server',
 );

 $client = new SoapClient(null, $options);

 echo $client->addNumber(10, 10);




//hello_server.php
function addNumber($x, $y)
{
return $x + $y;
}

$options = array(
'uri' => 'http://host_name/test_server',
'location' => 'http://host_name/test_server/wsdl/hello_server',
);


$server = new SoapServer(null, $options);
$server->addFunction("addNumber");
$server->handle();

Solution

  • A small mistake. The mistake is found in hello_client.php. Replace

     $options = array(
     'uri' => 'http://host_name/test_server',
     'location' => 'http://host_name/test_server/wsdl/hello_server',
      );
    

    to

     $options = array(
     'uri' => 'http://host_name/test_server',
     'location' => 'http://host_name/test_server/wsdl/hello_server.php',
      );