繁体   English   中英

SOAP:PHP WebService和.Net

[英]SOAP: PHP WebService and .Net

我必须通过.Net(C#,WPF)应用程序通过SOAP与PHP WebService连接。 我添加了对此服务的引用,生成了一些代理。

当我调用某些函数时:

var client = new someAPIPortTypeClient();
XmlNode[] response = client.status(arg1, arg2);    

我得到了回应:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:nakopitel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Body>
      <ns1:statusResponse>
         <statusReturn xsi:type="ns2:Map">
            <item>
               <key xsi:type="xsd:string">is_active</key>
               <value xsi:type="xsd:boolean">true</value>
            </item>
            <item>
               <key xsi:type="xsd:string">allow_add_paid</key>
               <value xsi:type="xsd:boolean">false</value>
            </item>
            <item>
               <key xsi:type="xsd:string">allow_search_free</key>
               <value xsi:type="xsd:boolean">true</value>
            </item>
            <item>
               <key xsi:type="xsd:string">allow_add_free</key>
               <value xsi:type="xsd:boolean">true</value>
            </item>
         </statusReturn>
      </ns1:statusResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

它解释为XmlNode[] ...

我如何才能使普通代理类与该SOAP服务一起使用? 我可以要求服务作者根据需要进行更改。

更新。 WSDL用于状态功能。

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

<definitions name="something" targetNamespace="urn:something" xmlns:typens="urn:something" 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="status">
    <part name="terminal" type="xsd:integer"/>
    <part name="code" type="xsd:string"/>
  </message>
  <message name="statusResponse">
    <part name="statusReturn" type="xsd:anyType"/>
  </message>
  <portType name="someAPIPortType">
    <operation name="status">
      <documentation>
        Get status
      </documentation>
      <input message="typens:status"/>
      <output message="typens:statusResponse"/>
    </operation>
    </portType>
    <binding name="someAPIBinding" type="typens:someAPIPortType">
    <operation name="status">
      <soap:operation soapAction="urn:someAPIAction"/>
      <input>
        <soap:body namespace="urn:something" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </input>
      <output>
        <soap:body namespace="urn:something" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </output>
    </operation>
    </binding>
  <service name="somethingService">
    <port name="someAPIPort" binding="typens:someAPIBinding">
      <soap:address location="http://something/soap/"/>
    </port>
  </service>
</definitions>

简而言之,如果您希望事情按照自己希望的方式工作,则必须定义一个适当的WSDL。 XSD_ANY只是在自找麻烦。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM