SOAP XML生成与手动

时间:2013-10-15 15:38:32

标签: php xml soap

我遇到使用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。

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

1 个答案:

答案 0 :(得分:2)

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

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