If a user wants to do data validation against a result set returned by JDBC step in SoapUI, but the Soap Response does not contain a corresponding data element, SoapUI provides no default way of creating an assertion for such element in Soap Response, i.e. assuming the JDBC step returns the following when executing a SQL query:
<Results>
<ResultSet fetchSize="10">
<Row rowNumber="1">
<ProdName>Prod Name</ProdName>
<ProdId>#2332</ProdId>
<ProdCat/>
</Row>
</ResultSet>
<Results>
In this case, the row in the database does not have a value for <ProdCat> (NULL). SoapUI provides no way of suppressing the generation of this XML element (<ProdCat>) in the JDBC Request step.
In case of Soap Response, assuming the web service provider generates the following (disregarding namespaces to simplify):
<soap:Envelope xmlns:soap="http://ift.tt/15QvkZ0">
<soap:Body>
...
<Product>
<ProductName>Prod Name</ProductName>
<ProductId>#2332</ProductId>
</Product>
</soap:Body>
</soap:Envelope>
(Note that all the sub-elements of <Product> are optional) The SoapUI obviously would be missing the data element <ProductCategory>. If we attempt to create an assertion for this data element in case the next time the JDBC step returns a value for the same record, that has been updated (<ProdCat>), a default Content Match assertion for <ProductCategory> would fail, i.e.
XPath Expression (actual)
//.../Product[1]/ProductCategory[1]/text()
XPath Expected Result (expected)
${JDBC Request Product#ResponseAsXML#//Results[1]/Row[1]/ProdCat[1]}
Executing this assertion will get you the following error:
[//.../Product[1]/ProductCategory[1]/text()]: Exception:Missing content for xpath [//.../Product[1]/ProductCategory[1]/text()] in Response
The question is, how to create an assertion that works for all the elements (in the accepted Schema in the Soap Response) regardless of whether they are being returned or not?
No comments:
Post a Comment