php - soap 信封是如何生成的,为什么 .NET 和 php 客户端会生成/接收不同的 so

我正在寻找有关在 Visual Studio 2010 中使用添加服务引用创建的 Web 服务客户端调用 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 命名空间,并表示他们无法使用结果。我假设他们正在解析响应信封而不考虑命名空间。

最佳答案

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

http://us2.php.net/soapclient

关于php - soap 信封是如何生成的,为什么 .NET 和 php 客户端会生成/接收不同的 soap 信封?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5170215/

相关文章:

c# - 如何在 C# 中从 IntPtr 获取 byte[]

svn - .htaccess 文件中的 If 语句,仅在特定目录中启用密码保护

sql-server-2005 - SQL Server 2005 Unicode字符串排序问题

winapi - IOCTL_MOUNTDEV_QUERY_UNIQUE_ID 的唯一性

maven - 如何在 Maven 中将依赖类包含到 war 项目的 WEB-INF/classes

ruby-on-rails - rails : running code once after lo

google-maps - 谷歌地图 API 最大坐标长度?

macos - 如何在 OS X 上从 gethostname() 获得一致的结果?

c# - 从 Datagrid 插入和更新 SQL Server

image - 将 com.lowagie.text.Image 转换为 BufferedImage