2

几天前,我遇到了一个 SOAP-Server 问题,让我抓狂。我也有一个非常简单的 SOAP-Client PHP 脚本来询问一个简单的 SOAP-Server PHP 脚本。

我的调试服务器上有这些脚本的精确副本,它们可以完美地工作(它只是一个 hello World 函数),但在生产中似乎无法从soap-client 获得soap-server 的响应。我不断收到“Procedure 'ns1:testHello' not present”错误(testHello 是函数名)。

我知道生产客户端正在工作,因为如果我从生产服务器调用开发 WSDL,它会完美运行。我确实认为它与 SOAP 服务器有某种关联,但我怎么能准确地知道它是否工作正常以及出了什么问题?

如果我看一下 infophp() 转储,我会看到 SOAP 服务器和客户端都已启用

Soap Client     enabled
Soap Server     enabled 

Directive   Local Value Master Value
soap.wsdl_cache 1   1
soap.wsdl_cache_dir /tmp    /tmp
soap.wsdl_cache_enabled 0   1
soap.wsdl_cache_limit   5   5
soap.wsdl_cache_ttl 0   86400

我尝试强制使用 SOAP_1_1 和 SOAP_1_2 版本,但没有更改。我已经尝试禁用每种缓存,但也没有任何更改。我读过“ns:X 函数不存在”通常是由于 WSDL 配置错误,但如果它是一个精确的副本怎么可能是错误的(t​​argetNamespace、xmlns:tns 和 soap:address 指向生产服务器的 URL 除外)

我开始认为这与某些 Web 服务器配置设置有关。有任何想法吗?我可以做哪些测试?

提前感谢很多。

我的服务器代码:

    ini_set("display_errors", "off");
    ini_set("soap.wsdl_cache_enabled", 0);
    ini_set('soap.wsdl_cache_ttl',0);

    $wsdl_url="http://SITE_URL/test.wsdl";


    function testHello($functionName){
        $return = "Hello, ".$functionName;
      return $return;
    } 

    $server= new SoapServer($wsdl_url, array('cache_wsdl' => WSDL_CACHE_NONE));
    $server->addFunction("testHello");
    $server->handle();

我的客户代码

ini_set("soap.wsdl_cache_enabled", 0);
ini_set('soap.wsdl_cache_ttl',0);
ini_set("display_errors", "on");

$wsdl_url="http://SITE_URL/test.wsdl";

$client=new SoapClient($wsdl_url , array('cache_wsdl' => WSDL_CACHE_NONE));

try{
  $t = $client-> testHello("Test");
  var_dump($t);
} catch(SoapFault $e){
  var_dump($e);
}

我的 WSDL 文件

<?xml version="1.0" encoding="UTF-8" ?>

<definitions name="TLN"
             targetNamespace="http://SITE_URL/test.wsdl"
             xmlns:tns="http://SITE_URL/test.wsdl"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
             xmlns="http://schemas.xmlsoap.org/wsdl/">

     <message name="testHelloRequest">
        <part name="functionName" type="xsd:string"/>
    </message>

    <message name="testHelloResponse">
        <part name="return" type="xsd:string"/>
    </message>

    <portType name="testHelloPortType">
        <operation name="testHello">
            <input message="tns:testHelloRequest" />
            <output message="tns:testHelloResponse" />
        </operation>
    </portType>

   <binding name="testHelloBinding" type="tns:testHelloPortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
        <operation name="testHello">
            <soap:operation soapAction="" />

            <input>
                <soap:body use="encoded" namespace="" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </input>
            <output>
                <soap:body use="encoded" namespace="" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </output>
        </operation>
    </binding>

    <documentation>testHello</documentation>

    <service name="testHelloService">
        <port name="testHelloPort" binding="testHelloBinding">
            <soap:address location="http://SITE_URL/server.php" />
        </port>
    </service>       


</definitions>
4

0 回答 0