我希望你能够协助翻译有关使用Visual Studio 2010中的添加服务引用创建的Web服务客户端进行调用并返回结果时会发生什么的信息。Soap请求信封是如何创建的,以及什么确定了其格式?Soap响应信封是如何创建的,以及什么确定了其格式?
这个过程一直被.NET抽象化了,我从未了解过它的实现方式,但我们有一个用户正在使用PHP,并且似乎在响应信封方面遇到了问题。以下是.NET和PHP代码的请求和响应的SOAP信封样例。
PHP请求:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://some.junk.url.xxxx.com">
<SOAP-ENV:Body>
<ns1:wsActionRouter>
<ns1:i_UserId>XXXX</ns1:i_UserId>
<ns1:i_Password>******</ns1:i_Password>
<ns1:ActionType>CS</ns1:ActionType>
<ns1:XmlData>
blah blah blah
</ns1:XmlData>
</ns1:wsActionRouter>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
.NET请求:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1"
xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" />
</s:Header>
<s:Body>
<wsActionRouter xmlns="http://some.junk.url.xxxx.com">
<i_UserId>XXXX</i_UserId>
<i_Password>******</i_Password>
<ActionType>CS</ActionType>
<XmlData>
blah blah blah
</XmlData>
</wsActionRouter>
</s:Body>
</s:Envelope>
PHP 响应:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<p287:wsActionRouterResponse xmlns:p287="http://some.junk.url.xxxx.com">
<p287:wsActionRouterReturn>
blah blah blah
</p287:wsActionRouterReturn>
</p287:wsActionRouterResponse>
</soapenv:Body>
</soapenv:Envelope>
.NET响应:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header />
<soapenv:Body>
<wsActionRouterResponse xmlns="http://some.junk.url.xxxx.com">
<wsActionRouterReturn>
blah blah blah
</wsActionRouterReturn>
</wsActionRouterResponse>
</soapenv:Body>
</soapenv:Envelope>
为什么信封不同?
PHP人员特别抱怨p287命名空间,并表示他们无法使用结果。我假设他们正在解析响应信封,但没有考虑命名空间。