PHP SOAP客户端致命错误

时间:2013-12-06 10:05:09

标签: php web-services soap wsdl

我无法在我的机器上运行我的PHP SOAP客户端。 这是我的PHP SOAP客户端:

    <?php

$params=array("SendMessageRequest" => 
    array( "GsbEnvelope" =>  
        array( "MessageHeader" => 
            array("SenderId" => "000000001",
                "ServiceId" => "000000002",
                "MessageId" => "833362f-063f-11e2-892e-0802200c9a62",
                "SenderTimeStamp" => "2013-12-03T14:39"),
                "Content" => array("MimeType" =>"application/xml","Data" =>"Nesto"))));

$client = new SoapClient("GSBService.wsdl", array(
                            "trace"=>1,
                            "exceptions"=>0,
                            "cache_wsdl" => 0));

print_r( $client->sendMessage($params));

echo "<p>Request :".htmlspecialchars($client->__getLastRequest()) ."</p>";
echo "<p>Response:".htmlspecialchars($client->__getLastResponse())."</p>";
echo "<p>Debug:".soapDebug($client)."</p>";
  ?>

这是WSDL文件:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="GSBService"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.apis-it.hr/umu/2013/services/GSBService"
    xmlns:umu="http://www.apis-it.hr/umu/2013/services/GSBService"
    xmlns:gsb="http://apis-it.hr/umu/2013/types/gsb">

  <wsdl:types>
    <xsd:schema targetNamespace="http://www.apis-it.hr/umu/2013/services/GSBService">
        <xsd:import namespace="http://apis-it.hr/umu/2013/types/gsb" schemaLocation="../schema/GSBSchema.xsd"/>
    </xsd:schema>
  </wsdl:types>

  <wsdl:message name="SendMessageRequest">
    <wsdl:part element="gsb:SendMessageRequest" name="request"/>
  </wsdl:message>
  <wsdl:message name="SendMessageResponse">
    <wsdl:part element="gsb:SendMessageResponse" name="response"/>
  </wsdl:message>

  <wsdl:message name="EchoRequest">
    <wsdl:part element="gsb:EchoRequest" name="request" />
  </wsdl:message>
  <wsdl:message name="EchoResponse">
    <wsdl:part element="gsb:EchoResponse" name="response" />
  </wsdl:message>

  <wsdl:portType name="GSBServicePortType">
    <wsdl:operation name="sendMessage">
      <wsdl:input message="umu:SendMessageRequest"/>
      <wsdl:output message="umu:SendMessageResponse"/>
    </wsdl:operation>
    <wsdl:operation name="echo">
        <wsdl:input message="umu:EchoRequest"/>
        <wsdl:output message="umu:EchoResponse"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="GSBService" type="umu:GSBServicePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sendMessage">
      <soap:operation soapAction="http://www.apis-it.hr/umu/2013/services/GSBService/sendMessage"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="echo">
        <soap:operation soapAction="http://www.apis-it.hr/umu/2013/services/GSBService/echo"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="GSBService">
    <wsdl:port binding="umu:GSBService" name="GSBServicePortType">
      <soap:address location="http://www.apis-it.hr:8849/GsbService"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

输出是:

Warning: SoapClient::SoapClient(http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd): failed to open stream: HTTP request failed! HTTP/1.1 500 Server Error in C:\xampp\htdocs\NIAS\HZZO-OKP-SOAP.php on line 15

Warning: SoapClient::SoapClient(): I/O warning : failed to load external entity "http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd" in C:\xampp\htdocs\NIAS\HZZO-OKP-SOAP.php on line 15

Fatal error: SOAP-ERROR: Parsing Schema: can't import schema from 'http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd' in C:\xampp\htdocs\NIAS\HZZO-OKP-SOAP.php on line 15

我可以通过网络浏览器轻松访问xmldsig-core-schema.xsd文件,我的管理员告诉我端口80和443没有被阻止。

2 个答案:

答案 0 :(得分:1)

此问题与出站端口8585有关。如果该端口在服务器中被阻塞,则服务器无法通过该端口访问公共互联网。因此,通过解除阻塞来允许端口访问公共互联网。这只是解决方案,而且有效。

答案 1 :(得分:0)

我通过在php.ini中启用函数“libxml_disable_entity_loader”解决了这个问题

  

注意:您还必须在应用程序的启动脚本中的某处调用libxml_disable_entity_loader(false)以启用外部XML实体的加载。