Posted by: devakara on: October 3, 2008
Assertions are generally the simple and most sought validations that can be enforced in SOAP UI.
For SOAP response we have an assertion step called ‘XPath Match‘, which validates the value yielded by the specified xpath with the one provided staticly.
When we add ‘XPath Match’ assertion using the Add Assertion button, we see the below window.
There is a button called ‘Declare‘ (present in free version of SOAP UI also), it automatically declares all the namespaces of SOAP response. After declaring the namespaces using this ‘Declare’, mention the xpath of the node whose value is to be validated. Here the xpath could start from the node which comes just after the <soap:Body> node (i.e., <soap:Body> node’s immediate child). For example, if say the response xml is:
then to validate on the value of ‘Status‘ node, the xpath that should be present in XPath Expression blockalong with all the declared namespaces is
//p77:GetReportResponse/p77:GetReport/ReportResponse/Status
And, now we need to provide some expected value, inside ‘Expected Result’ block which shall validated against the corresponding node value. There is an option called ‘Select from current‘, which actually fetches the value of that xpath, from the current response. Another option called ‘Test‘, is used to test right away.
I have a question,
I use SoapUI 2.5. After I added XPath match Assertion step and just let SoapUI automatically declared all namespaces from the response XML, I kept getting the assertion error:
RuntimeException:net.sf.saxon.trans.XPathException: XPath syntax error at char 0 in {}: Unexpected token “” in path expression.
Do you know why? Thx.
Decalare required namespaces there, issue will be resolved
Hi,
After declaring the Name space by using the declare option from tool and from the expected result i i selected the option ” select from current” than i got below mentioned error message..
“java.lang.RuntimeException: net.sf.saxon.trans.XPathException: XPath syntax error at char 0 in {}: Unexpected token ” ” in path expression”
Thanks in Advance
January 13, 2009 at 3:01 am
Hi…I have a small question.
Suppose for the given below response I want to get value of “returnedItems” using Xpath. How I will get that value.
SOAP-ENV:Envelope xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”>
Item1
January 14, 2009 at 5:14 pm
Hi Sandeep,
Might be an oversight or misapprehension by the site, I see an incomplete SOAP response in your comment above.
Could you send me that response again, so that I can help.
Thanks
Devakara