geoffcamp
16 years agoContributor
Using assertions to validate responses that needs ordering
Hi,
I've got a response that is (correctly) returning the same set of tags multiple times. For example:
5261260886931759
PERSON
2211260886918334
PERSON
4131260886927904
ORG
What I want to do is use an assertion to check that the response I'm receiving against a previously stored "correct" response.
I had used an XPath Match for this initially. However I now know that for a specific database the order in which the records are returned is not fixed, therefore when they are returned in a differing order to the stored response then the assertion (correctly) fails, even though the reponse is valid
I've tried using XQUery
declare namespace soapenc='http://schemas.xmlsoap.org/soap/encoding/';
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace v02='http://www.Test.com/party/facade/interfaces/PersonIsV02';
{for $x in //getPartyCandidateListResponse/candidateParty/party/partyIdentifier/string()
order by $x return{data($x)} }
Which correctly returns the partyIdentifiers in ascending numeric order
2211260886918334
4131260886927904
5261260886931759
This would allow me to check that the correct records have been returned, which is useful, however what I really want returned is the full XML response, but where the sets of tags have been re-ordered.
I've tried a number of things which I don't bore you with (but can expand on if you're interested), however each of them has met with a varying degree of failure.
Is there a way to do this within SOAP UI? Is it something that can be accomplished within XQuery, or is there a way this can be done within the Grovvy scripting?
Any help would be appreciated.
Cheers,
Geoff
I've got a response that is (correctly) returning the same set of tags multiple times. For example:
What I want to do is use an assertion to check that the response I'm receiving against a previously stored "correct" response.
I had used an XPath Match for this initially. However I now know that for a specific database the order in which the records are returned is not fixed, therefore when they are returned in a differing order to the stored response then the assertion (correctly) fails, even though the reponse is valid
I've tried using XQUery
declare namespace soapenc='http://schemas.xmlsoap.org/soap/encoding/';
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace v02='http://www.Test.com/party/facade/interfaces/PersonIsV02';
{for $x in //getPartyCandidateListResponse/candidateParty/party/partyIdentifier/string()
order by $x return
Which correctly returns the partyIdentifiers in ascending numeric order
This would allow me to check that the correct records have been returned, which is useful, however what I really want returned is the full XML response, but where the sets of tags have been re-ordered.
I've tried a number of things which I don't bore you with (but can expand on if you're interested), however each of them has met with a varying degree of failure.
Is there a way to do this within SOAP UI? Is it something that can be accomplished within XQuery, or is there a way this can be done within the Grovvy scripting?
Any help would be appreciated.
Cheers,
Geoff