SOAP请求中的<req:xxx>和<ns1:xxx>有何不同

时间:2016-09-21 07:14:38

标签: xml web-services soap soapui

有人可以解释soap请求xml架构中<req:xxx><ns1:xxx>用法之间的区别吗?

例如: -

第一个SOAP请求XML架构

  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://olp.bank.com/payement/service/olppaymentmanager/req">
   <soapenv:Header/>
   <soapenv:Body>
      <req:initiatePaymentDetailsReq>
         <olpIdAlias>****</olpIdAlias>
         <merchantId>****</merchantId>
         <merchantRefNum>234324</merchantRefNum>
         <paymentAmount>200</paymentAmount>
         <paymentCurrency>SAR</paymentCurrency>
         <dynamicMerchantLandingURL></dynamicMerchantLandingURL>
         <dynamicMerchantFailureURL></dynamicMerchantFailureURL>
      </req:initiatePaymentDetailsReq>
   </soapenv:Body>
</soapenv:Envelope>

第二个XML请求架构

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:brsmembersapi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:ValidateMemberLogin>
      <login xsi:type="ns1:LoginCredentials">
        <clientAPIVersion xsi:type="xsd:int">0</clientAPIVersion>
        <username xsi:type="xsd:string">someapiusername</username>
        <password xsi:type="xsd:string">someapipassword</password>
      </login>
      <memberLogin xsi:type="ns1:MemberLoginCredentials">
        <username xsi:type="xsd:string">somememberusername</username>
        <password xsi:type="xsd:string">somememberpassword</password>
      </memberLogin>
      </ns1:ValidateMemberLogin>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

在使用<req:>的第一个soap请求中,例如: - <req:initiatePaymentDetailsReq>在第二个肥皂请求中<ns1:>例如: - <ns1:ValidateMemberLogin> 他们之间有什么不同。

1 个答案:

答案 0 :(得分:1)

名称空间前缀不同的事实纯粹是装饰性的,您可以选择任何您喜欢的名称空间前缀,因为它的唯一目的是充当名称空间URI的本地缩写。

但是这两个消息使用不同的名称空间URI这一事实非常重要。 (一个使用http://olp.bank.com/payement/service/olppaymentmanager/req,另一个使用urn:brsmembersapi)这意味着这两个消息使用完全不同的词汇表,由不同的人定义并且意味着不同的东西。

当没有相似性时,很难“解释差异” - 就像要求解释考古学和博若莱之间的差异一样。