LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1483|回复: 0

php用Soap调用C#的Soap服务端的错误

[复制链接]
发表于 2008-1-22 19:14:32 | 显示全部楼层 |阅读模式
http://192.168.1.200/CMSWebService/WebService1.asmx?wsdl
获取的结果

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  3.   <wsdl:types>
  4.     <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
  5.       <s:element name="GetIP">
  6.         <s:complexType>
  7.           <s:sequence>
  8.             <s:element minOccurs="0" maxOccurs="1" name="username" type="s:string" />
  9.           </s:sequence>
  10.         </s:complexType>
  11.       </s:element>
  12.       <s:element name="GetIPResponse">
  13.         <s:complexType>
  14.           <s:sequence>
  15.             <s:element minOccurs="0" maxOccurs="1" name="GetIPResult" type="s:string" />
  16.           </s:sequence>
  17.         </s:complexType>
  18.       </s:element>
  19.       <s:element name="addUserJob">
  20.         <s:complexType>
  21.           <s:sequence>
  22.             <s:element minOccurs="1" maxOccurs="1" name="p1" type="s:int" />
  23.             <s:element minOccurs="1" maxOccurs="1" name="p2" type="s:int" />
  24.             <s:element minOccurs="1" maxOccurs="1" name="p3" type="s:int" />
  25.           </s:sequence>
  26.         </s:complexType>
  27.       </s:element>
  28.       <s:element name="addUserJobResponse">
  29.         <s:complexType>
  30.           <s:sequence>
  31.             <s:element minOccurs="0" maxOccurs="1" name="addUserJobResult" type="s:string" />
  32.           </s:sequence>
  33.         </s:complexType>
  34.       </s:element>
  35.     </s:schema>
  36.   </wsdl:types>
  37.   <wsdl:message name="GetIPSoapIn">
  38.     <wsdl:part name="parameters" element="tns:GetIP" />
  39.   </wsdl:message>
  40.   <wsdl:message name="GetIPSoapOut">
  41.     <wsdl:part name="parameters" element="tns:GetIPResponse" />
  42.   </wsdl:message>
  43.   <wsdl:message name="addUserJobSoapIn">
  44.     <wsdl:part name="parameters" element="tns:addUserJob" />
  45.   </wsdl:message>
  46.   <wsdl:message name="addUserJobSoapOut">
  47.     <wsdl:part name="parameters" element="tns:addUserJobResponse" />
  48.   </wsdl:message>
  49.   <wsdl:portType name="WebService1Soap">
  50.     <wsdl:operation name="GetIP">
  51.       <wsdl:input message="tns:GetIPSoapIn" />
  52.       <wsdl:output message="tns:GetIPSoapOut" />
  53.     </wsdl:operation>
  54.     <wsdl:operation name="addUserJob">
  55.       <wsdl:input message="tns:addUserJobSoapIn" />
  56.       <wsdl:output message="tns:addUserJobSoapOut" />
  57.     </wsdl:operation>
  58.   </wsdl:portType>
  59.   <wsdl:binding name="WebService1Soap" type="tns:WebService1Soap">
  60.     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
  61.     <wsdl:operation name="GetIP">
  62.       <soap:operation soapAction="http://tempuri.org/GetIP" style="document" />
  63.       <wsdl:input>
  64.         <soap:body use="literal" />
  65.       </wsdl:input>
  66.       <wsdl:output>
  67.         <soap:body use="literal" />
  68.       </wsdl:output>
  69.     </wsdl:operation>
  70.     <wsdl:operation name="addUserJob">
  71.       <soap:operation soapAction="http://tempuri.org/addUserJob" style="document" />
  72.       <wsdl:input>
  73.         <soap:body use="literal" />
  74.       </wsdl:input>
  75.       <wsdl:output>
  76.         <soap:body use="literal" />
  77.       </wsdl:output>
  78.     </wsdl:operation>
  79.   </wsdl:binding>
  80.   <wsdl:binding name="WebService1Soap12" type="tns:WebService1Soap">
  81.     <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
  82.     <wsdl:operation name="GetIP">
  83.       <soap12:operation soapAction="http://tempuri.org/GetIP" style="document" />
  84.       <wsdl:input>
  85.         <soap12:body use="literal" />
  86.       </wsdl:input>
  87.       <wsdl:output>
  88.         <soap12:body use="literal" />
  89.       </wsdl:output>
  90.     </wsdl:operation>
  91.     <wsdl:operation name="addUserJob">
  92.       <soap12:operation soapAction="http://tempuri.org/addUserJob" style="document" />
  93.       <wsdl:input>
  94.         <soap12:body use="literal" />
  95.       </wsdl:input>
  96.       <wsdl:output>
  97.         <soap12:body use="literal" />
  98.       </wsdl:output>
  99.     </wsdl:operation>
  100.   </wsdl:binding>
  101.   <wsdl:service name="WebService1">
  102.     <wsdl:port name="WebService1Soap" binding="tns:WebService1Soap">
  103.       <soap:address location="http://192.168.1.200/CMSWebService/WebService1.asmx" />
  104.     </wsdl:port>
  105.     <wsdl:port name="WebService1Soap12" binding="tns:WebService1Soap12">
  106.       <soap12:address location="http://192.168.1.200/CMSWebService/WebService1.asmx" />
  107.     </wsdl:port>
  108.   </wsdl:service>
  109. </wsdl:definitions>
复制代码


我的PHP代码
[PHP]
<?php
try {
        $fwsdl = "http://192.168.1.200/CMSWebService/WebService1.asmx?wsdl";
        $client = new SoapClient($fwsdl);
        var_dump($client);
        var_dump($client->__getFunctions());
        //echo $client->GetIP();
} catch (Exception $e) {
        echo $e->getMessage();
}
?>
[/PHP]

运行结果

  1. mikkoyue [ ~/web_project/soap ]$ php c2csharp.php
  2. object(SoapClient)#1 (2) {
  3.   ["_soap_version"]=>
  4.   int(1)
  5.   ["sdl"]=>
  6.   resource(4) of type (Unknown)
  7. }
  8. array(4) {
  9.   [0]=>
  10.   string(38) "GetIPResponse GetIP(GetIP $parameters)"
  11.   [1]=>
  12.   string(53) "addUserJobResponse addUserJob(addUserJob $parameters)"
  13.   [2]=>
  14.   string(38) "GetIPResponse GetIP(GetIP $parameters)"
  15.   [3]=>
  16.   string(53) "addUserJobResponse addUserJob(addUserJob $parameters)"
  17. }
  18. mikkoyue [ ~/web_project/soap ]$
复制代码


很明显,获取到的函数列表不正确。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表