首頁 >後端開發 >php教程 >php呼叫soap介面出報錯

php呼叫soap介面出報錯

WBOY
WBOY原創
2016-10-11 14:23:281135瀏覽

<code>SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://27.148.153.106:9090/mpserver/services/CykProcService' : Extra content at the end of the document in /Users/haua/Desktop/zuji_web/www/quan.189go.cn/test2.php:47 Stack trace: #0 /Users/haua/Desktop/zuji_web/www/quan.189go.cn/test2.php
</code>

上面是報錯

<code>$client = new SoapClient("http://27.148.153.106:9090/mpserver/services/CykProcService");
print_r($client->__getFunctions());
</code>

上面是我的程式碼,下面是wsdl

<code><?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://client.webservice.mpserver.ptnetwork.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://client.webservice.mpserver.ptnetwork.com" xmlns:intf="http://client.webservice.mpserver.ptnetwork.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->

   <wsdl:message name="doProcResponse">

      <wsdl:part name="doProcReturn" type="xsd:int"/>

   </wsdl:message>

   <wsdl:message name="doProcRequest">

      <wsdl:part name="seq" type="xsd:string"/>

      <wsdl:part name="userId" type="xsd:string"/>

      <wsdl:part name="type" type="xsd:int"/>

      <wsdl:part name="sign" type="xsd:string"/>

   </wsdl:message>

   <wsdl:portType name="CykProcService">

      <wsdl:operation name="doProc" parameterOrder="seq userId type sign">

         <wsdl:input message="impl:doProcRequest" name="doProcRequest"/>

         <wsdl:output message="impl:doProcResponse" name="doProcResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="CykProcServiceSoapBinding" type="impl:CykProcService">

      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="doProc">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="doProcRequest">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://client.webservice.mpserver.ptnetwork.com" use="encoded"/>

         </wsdl:input>

         <wsdl:output name="doProcResponse">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://client.webservice.mpserver.ptnetwork.com" use="encoded"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="CykProcServiceService">

      <wsdl:port binding="impl:CykProcServiceSoapBinding" name="CykProcService">

         <wsdlsoap:address location="http://27.148.153.106:9090/mpserver/services/CykProcService"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>
</code>

上回有一次呼叫他們的http接口,也是設定了header才可以(程式碼見下方),不知道這個soap怎麼設定

<code>$ch = curl_init();
curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (//不知道为什么一定要这个他们才能接收到post数据
    'content-type: text/html'
));</code>

回覆內容:

<code>SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://27.148.153.106:9090/mpserver/services/CykProcService' : Extra content at the end of the document in /Users/haua/Desktop/zuji_web/www/quan.189go.cn/test2.php:47 Stack trace: #0 /Users/haua/Desktop/zuji_web/www/quan.189go.cn/test2.php
</code>

上面是報錯

<code>$client = new SoapClient("http://27.148.153.106:9090/mpserver/services/CykProcService");
print_r($client->__getFunctions());
</code>

上面是我的程式碼,下面是wsdl

<code><?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://client.webservice.mpserver.ptnetwork.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://client.webservice.mpserver.ptnetwork.com" xmlns:intf="http://client.webservice.mpserver.ptnetwork.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->

   <wsdl:message name="doProcResponse">

      <wsdl:part name="doProcReturn" type="xsd:int"/>

   </wsdl:message>

   <wsdl:message name="doProcRequest">

      <wsdl:part name="seq" type="xsd:string"/>

      <wsdl:part name="userId" type="xsd:string"/>

      <wsdl:part name="type" type="xsd:int"/>

      <wsdl:part name="sign" type="xsd:string"/>

   </wsdl:message>

   <wsdl:portType name="CykProcService">

      <wsdl:operation name="doProc" parameterOrder="seq userId type sign">

         <wsdl:input message="impl:doProcRequest" name="doProcRequest"/>

         <wsdl:output message="impl:doProcResponse" name="doProcResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="CykProcServiceSoapBinding" type="impl:CykProcService">

      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="doProc">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="doProcRequest">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://client.webservice.mpserver.ptnetwork.com" use="encoded"/>

         </wsdl:input>

         <wsdl:output name="doProcResponse">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://client.webservice.mpserver.ptnetwork.com" use="encoded"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="CykProcServiceService">

      <wsdl:port binding="impl:CykProcServiceSoapBinding" name="CykProcService">

         <wsdlsoap:address location="http://27.148.153.106:9090/mpserver/services/CykProcService"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>
</code>

上回有一次呼叫他們的http接口,也是設定了header才可以(程式碼見下方),不知道這個soap怎麼設定

<code>$ch = curl_init();
curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (//不知道为什么一定要这个他们才能接收到post数据
    'content-type: text/html'
));</code>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn