php中的SOAP服务器错误?

时间:2015-01-01 06:01:51

标签: php web-services soap wsdl

我想在非wsdl模式下通过SOAP连接两台计算机。 为了测试,我写了两个文件,hello_client.php和hello_server.php 但它显示错误。

  

“致命错误:未捕获的SoapFault异常:[E:\ xampp \ htdocs \ test_server \ wsdl \ hello_client.php中的SOAP不支持[客户端] DTD:10堆栈跟踪:#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)在第10行的E:\ xampp \ htdocs \ test_server \ wsdl \ hello_client.php中抛出#2 {main}“

我的代码:

// 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();

1 个答案:

答案 0 :(得分:0)

一个小错误。 在hello_client.php中发现了错误。 替换

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

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