我遇到一些重大问题上试图消耗使用ASP.NET我的PHP SOAP Web服务PHP的SOAP的WebService。有问题的web服务是基于PHP的SOAP扩展,由下面的WSDL descibed:消费与ASP.NET
<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="MyServices"
targetNamespace="http://mydomain.com/api/soap/v11/services"
xmlns:tns="http://mydomain.com/api/soap/v11/services"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsd1="http://mydomain.com/api/soap/v11/services"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema targetNamespace="http://mydomain.com/api/soap/v11/services" xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="ServiceType">
<all>
<element name="id" type="xsd:int" minOccurs="1" maxOccurs="1" />
<element name="name" type="xsd:string" minOccurs="1" maxOccurs="1" />
<element name="cost" type="xsd:float" minOccurs="1" maxOccurs="1" />
</all>
</complexType>
<complexType name="ArrayOfServiceType">
<all>
<element name="Services" type="ServiceType" minOccurs="0" maxOccurs="unbounded" />
</all>
</complexType>
</schema>
</types>
<message name="getServicesRequest">
<part name="postcode" type="xsd:string" />
</message>
<message name="getServicesResponse">
<part name="Result" type="xsd1:ArrayOfServiceType"/>
</message>
<portType name="ServicesPortType">
<operation name="getServices">
<input message="tns:getServicesRequest"/>
<output message="tns:getServicesResponse"/>
</operation>
</portType>
<binding name="ServicesBinding" type="tns:ServicesPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getServices">
<soap:operation soapAction="http://mydomain.com/api/soap/v11/services/getServices" />
<input>
<soap:body use="encoded" namespace="urn:my:services" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:my:services" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="MyServices">
<port name="ServicesPort" binding="tns:ServicesBinding">
<soap:address location="http://mydomain.com/api/soap/v11/services"/>
</port>
</service>
</definitions>
我可以成功地产生了这个WSDL在Visual Studio中的代理类,但在试图调用该getServices方法我带有一个例外:
System.Web.Services.Protocols.SoapHeaderException:过程“串”不存在
在SOAP服务器端检查的原始数据后,我的PHP SOAP客户端发出请求像这样:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<postcode xsi:type="xsd:string">ln4 4nq</postcode>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
尽管净代理类是这样做的:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://mydomain.com/api/soap/v11/services"
xmlns:types="http://mydomain.com/api/soap/v11/services/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<xsd:string xsi:type="xsd:string">LN4 4NQ</xsd:string>
</soap:Body>
</soap:Envelope>
我只能假设在邮政编码参数被发送的方式不同的是问题所在,但主要是PHP开发人员我不知道这里发生了什么。我有一种感觉,我在WSDL中错过了一些至关重要的东西,因为我已经看到了无数的“使用.Net来使用PHP SOAP WebServices”的例子,这些例子似乎暗示它“正常工作”。
任何建议到哪里我在这里输了球将不胜感激。我现在用了差不多一整天的时间提前这现在;-)
感谢,
杰米
这很容易滑倒......在SOAP :-D – andychase 2012-09-21 18:46:22