2016-04-20 12 views
1

Ich bin nicht in der Lage, Xpath-Wert "MatchFound" für die unten xml in Soapui zu bekommen. Ich versuche die Eigenschaftenübertragungsfunktion.kann Xpath-Wert nicht aus Soapui erhalten

Ich habe versucht, XPath folgende:

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> 
+0

der NamespaceURI Sie für ns0 erklärt enthält eine Hinter '/', der Namensraum in dem Dokument nicht –

+0

tut Folgendes kann Ihre XPath "// BarclsCustomerValidationResponse/oAddressVerificationDetails/ns0: matchedFound" sein. Die beste Vorgehensweise besteht darin, Namensräume zu maskieren. Jetzt sieht es aus wie "// BarclsCustomerValidationResponse/oAddressVerificationDetails/*: matchedFound" – Ramu

Antwort

0

Hier sind einige der Probleme:

  • Namespace ns0 im XPath/XQuery zugewiesen URI
  • die XML Standard-Namespace erklärt bei BarclsCustomerValidationResponse Element stimmt nicht mit der in der XML-Spiel . Das bedeutet BarclsCustomerValidationResponse und alle Nachfolgerelemente ohne Präfix befinden sich im selben Namensraum. Sie benötigen einen anderen Präfix zu erklären, um es in dem Standard-Namespace-URI zuzuordnen, und das Präfix entsprechend in den XPath

folgende Arbeiten für mich:

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 

Demo: http://www.xpathtester.com/xquery/b8f1f1e9e0c64af37a2e398d5b911569

0

BarclaysCustomerValidationResponse im Namensraum ist http://BHKYC/BarclaysCustomerValidation.tws, so dass Ihr XPath-Ausdruck /BarclaysCustomerValidationResponse/ es nicht finden kann. Gleiches gilt für seine untergeordneten Elemente, sofern sie kein bestimmtes Namespacepräfix wie ns0: haben.

0

Nur Zum Lesen von XML in SoapUI müssen Sie sich nicht um Namespaces kümmern. Wie Sie festgestellt haben, machen sie den XPath unnötig kompliziert. Für Ihren Fall wird etwas so einfaches wie dieses ausreichen.

//*:matchedFound