【问题标题】:How are soap envelopes generated and why would .NET and php clients produce/receive different soap envelopes?肥皂信封是如何生成的,为什么 .NET 和 php 客户端会生成/接收不同的肥皂信封?
【发布时间】:2011-07-07 09:55:04
【问题描述】:

我正在寻找有关当使用 Visual Studio 2010 中的添加服务引用创建的 Web 服务客户端调用 Web 服务并返回结果时会发生什么的信息。

soap 请求信封是如何创建的,格式是什么? 肥皂响应信封是如何创建的,格式由什么决定?

这个过程一直被 .net 抽象出来,我从来没有研究过它是如何完成的,但是我们有一个使用 php 的用户,并且似乎对响应信封有问题。下面我将提供一个肥皂信封示例,用于请求和来自 .net 和 php 代码的响应。

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。

标签: php .net soap webservice-client


【解决方案1】:

确保他们使用的是 PHP5 SoapClient,并且他们在使用该结果时应该没有问题。

http://us2.php.net/soapclient

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多