如何生成SOAP信封,为什么.NET和PHP客户端会产生/接收不同的SOAP信封?

3

我希望你能够协助翻译有关使用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命名空间,并表示他们无法使用结果。我假设他们正在解析响应信封,但没有考虑命名空间。

欢迎来到软件标准的有趣世界 :) (如果这句话冒犯了您,我很抱歉)但我已经在这个行业里工作了相当长时间,对于像这样的事情我感到非常厌烦,我不知道是无知还是恶意导致了这种情况。HTML应该是标准,但它不是;SOAP应该是标准,但它不是;SQL应该是标准,但它不是。我不知道为什么他们还要给它们命名为标准。到目前为止,我发现最标准化的只有JSON。 - Catalin Marin
1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接