1

我遇到了使用 SOAP 的 API 的问题。我的客户端是用 PHP 编写的,并产生以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://webportal.gb.co.uk/GBPortal" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Body>
      <ns1:CreateAuthenticatedSession xsi:type="ns1:CreateAuthenticatedSession">
         <szUsername xsi:type="xsd:string">...</szUsername>
         <szPassword xsi:type="xsd:string">...</szPassword>
      </ns1:CreateAuthenticatedSession>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

文档中的参考 XML 是:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <CreateAuthenticatedSession xmlns="http://webportal.gb.co.uk/GBPortal">
      <szUsername>string</szUsername>
      <szPassword>string</szPassword>
    </CreateAuthenticatedSession>
  </soap:Body>
</soap:Envelope>

据我所知,在功能上是相同的。

我是否遗漏了任何会导致 API 拒绝 XML 的差异?宁愿不必通过使用字符串连接来生成 XML。

编辑:如果没有功能差异,请留下答案。

4

1 回答 1

2

这两个请求在功能上是相同的。由您的客户端生成的只是为 and 使用不同的命名空间名称<Envelop><Body>但这仍然指向与文档版本 ( http://schemas.xmlsoap.org/soap/envelope/) 相同的命名空间。

CreateAuthenticatedSession此外,您的客户端版本在元素上使用命名空间,而文档版本只是声明了xmlns属性。

于 2013-10-15T15:50:52.363 回答