考虑名称空间的SOAP请求的Xpath

时间:2017-03-22 09:50:31

标签: xml web-services xpath soap

我想知道是否有人可以帮助我解决使用XPath遍历SOAP响应以挑选数据的要求。

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
  <ns2:preferredPaymentSearch  xmlns:ns2="http://website.abc.com">
     <header>
        <issueAudit>
           <info>
              <issues>
                 <issue severity="INFO" issueId="7f32d1f1-8355-4af3-8862-6e3b66061c41" host="server.test.com/10.2.333.46" issueMessage="qqdG6jVIqIkw459wSj0ymokh" issueCode="TrackingId" timestamp="2017-03-22T09:36:40.362Z" />
                 <issue severity="INFO" issueId="220f5972-eed0-43e3-be72-cdbea1798520" host="server.test.mcom/10.2.333.46" issueMessage="server.test.com/10.2.333.46" issueCode="Host" timestamp="2017-03-22T09:36:40.362Z" />
              </issues>
           </info>
           <warnings>
              <issues />
           </warnings>
           <errors>
              <issues />
           </errors>
        </issueAudit>
        <status>SUCCESS</status>
        <ver>1.0.0-SNAPSHOT</ver>
     </header>
     <results>
        <preferredPaymentResults>
           <preferredPaymentCriterion>
              <productSupplier>
                 <ns2:actorCode>ABC</ns2:actorCode>
              </productSupplier>
              <requiredFunds amount="59.29" currency="GBP" />
           </preferredPaymentCriterion>
           <preferredPaymentOption>
              <preferredCardOption>
                 <cardForm>PHYSICAL</cardForm>
                 <cardType>VISA_CREDIT</cardType>
                 <provider>lodged</provider>
              </preferredCardOption>
           </preferredPaymentOption>
        </preferredPaymentResults>
     </results>
  </ns2:preferredPaymentSearch>

如何获取<status>代码中的数据?

我原以为以下会返回所需的“SUCCESS”数据:

//soap:Body/descendant::*[name()='status']

1 个答案:

答案 0 :(得分:0)

//header/status/text()

请尝试使用上面的xpath,它将提供&#34; SUCCESS&#34;