【发布时间】:2015-01-02 16:58:40
【问题描述】:
我正在为我拥有的两个站点之间的通信制作一个简单的 Web 服务。
由于它只是一个基本的应用程序,我一直在没有 WSDL 文件的情况下工作,所以在 PHP 手册中称为 non-WSDL mode。
这基本上是客户端的样子:
$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:!
使用$client->__getLastRequest(),我得到:
<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 专家,但在我看来,客户端在发出请求时导致错误 - 还是服务器误解了它?
我该如何解决这个问题?
【问题讨论】: