无法从soapui获取xpath值

时间:2016-04-20 11:45:41

标签: xpath soapui

我无法获得xpath值" MatchFound"对于soapui中的下面的xml。 我正在尝试财产转移功能。

我尝试过XPath:

declare namespace ns0='http://KYC/';
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
/soapenv:Envelope/soapenv:Body/BarclaysCustomerValidationResponse/oCasaDetailByRefNoDetails/oCasaStatusByRefNoDetails/oRiskProfileClientData/oGetFraudInformationData/oAddressVerificationDetails/ns0:matchedFound

XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <BarclsCustomerValidationResponse xmlns="http://BHKYC/BarclaysCustomerValidation.tws">
         <oCasaByIdNoDetails>
            <ns0:casaByIdNoResults xmlns:ns0="http://KYC">
               <ns0:item/>
            </ns0:casaByIdNoResults>
         </oCasaByIdNoDetails>
         <oCasaDetailByRefNoDetails/>
         <oCasaStatusByRefNoDetails/>
         <oRiskProfileClientData/>
         <oGetFraudInformationData/>
         <oAddressVerificationDetails>
            <ns0:enquiryid xmlns:ns0="http://KYC">51644325</ns0:enquiryid>
            <ns0:enquiryresultid xmlns:ns0="http://KYC">52146422</ns0:enquiryresultid>
            <ns0:matchedFound xmlns:ns0="http://KYC">false</ns0:matchedFound>
            <ns0:numberOfMatches xmlns:ns0="http://KYC">1</ns0:numberOfMatches>
            <ns0:firstMatchUpdatedDate xmlns:ns0="http://KYC">2016-03-31</ns0:firstMatchUpdatedDate>
            <ns0:secondMatchUpdatedDate xmlns:ns0="http://KYC"/>
            <ns0:mostRecentAddressIsMatched xmlns:ns0="http://KYC">false</ns0:mostRecentAddressIsMatched>
         </oAddressVerificationDetails>
         <oCasaPS/>
         <pid>21691</pid>
      </BarclsCustomerValidationResponse>
   </soapenv:Body>
</soapenv:Envelope>

3 个答案:

答案 0 :(得分:0)

BarclaysCustomerValidationResponse位于命名空间http://BHKYC/BarclaysCustomerValidation.tws中,因此您的XPath表达式/BarclaysCustomerValidationResponse/无法找到它。它的子元素也是如此,除非它们具有特定的名称空间前缀,如ns0:

答案 1 :(得分:0)

以下是一些问题:

  • 在XPath / XQuery中分配给ns0的名称空间URI与XML中的名称空间不匹配
  • XML在BarclsCustomerValidationResponse元素处声明了默认命名空间。这意味着BarclsCustomerValidationResponse和所有没有前缀的后代元素都在同一名称空间中。您需要声明另一个前缀,将其映射到默认名称空间URI,并在XPath中相应地使用前缀

以下适用于我:

declare namespace ns0='http://KYC';
declare namespace d='http://BHKYC/BarclaysCustomerValidation.tws';
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';

/soapenv:Envelope
/soapenv:Body
/d:BarclsCustomerValidationResponse
/d:oAddressVerificationDetails
/ns0:matchedFound

演示:http://www.xpathtester.com/xquery/b8f1f1e9e0c64af37a2e398d5b911569

答案 2 :(得分:0)

只是为了在SoapUI中读取XML,您不需要为命名空间而烦恼。正如您所发现的,它们使XPath不必要地变得复杂。对于你的情况,这样简单就足够了。

//*:matchedFound