我正在制作一个简单的网络服务,用于我拥有的两个网站之间的通信。
由于它只是一个基本应用程序,我一直在没有 WSDL 文件的情况下工作,所以在non-WSDL mode
正如 PHP 手册所称。
这基本上就是客户端的样子:
$client = new SoapClient(null, array('location' => $location, 'uri' => '', 'trace' => TRUE));
$res = $client->__soapCall('myFunc', array($param));
在服务器端,我有一个名为myFunc
:
$soap = new SoapServer(null, array('uri' => ''));
$soap->addFunction('myFunc');
//Use the request to invoke the service
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$soap->handle();
}
当我实际尝试调用myFunc
函数,我得到错误:
Function 'ns1:myFunc' doesn't exist
由于某种原因,soap 服务器正在预置ns1:
到函数名!
Using $client->__getLastRequest()
, I get:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getTopElement>
<param0 xsi:type="xsd:string">rightcolBox</param0>
</ns1:getTopElement>
</SOAP-ENV:Body>
我不是 SOAP 专家,但在我看来,是客户端在发出请求时导致了错误,还是服务器误解了它?
我该如何解决这个问题?