Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

qaf - Not able to validate xpath from soap api response

In Qmetry, trying to validate xpath from the soap api response. But it returns false.

API response has root is <soapenv:Envelope (can't paste full response as its content is big)

When tried running below steps. With both options below.

And response should have xpath '/soapenv:Envelope'
And response should have xpath '/Envelope'

This returns False though the response has xpath.

Can any one please help me in resolving this isse?

question from:https://stackoverflow.com/questions/65661901/not-able-to-validate-xpath-from-soap-api-response

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If Envelope is root element you should not use it in argument to response should have xpath. Given following as sample response:

<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Body xmlns:m = "http://www.example.com/quotation">
      <m:GetQuotationResponse>
         <m:Quotation>Here is the quotation</m:Quotation>
      </m:GetQuotationResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The root node (Envelope in this case)need not to be added in xpath or used as . Following xpaths should work:

./Body
.//Body
//Body
//GetQuotationResponse
//Body/GetQuotationResponse/Quotation
//GetQuotationResponse/Quotation
//Quotation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...