Forum Discussion

saurabhsharma09's avatar
saurabhsharma09
Contributor
11 years ago

[Res] How to validate Service Response against JDBC response

Hi,

I am trying to validate REST service response against JDBC response.
The problem I am facing is that the xml response returned by REST Service has no defined order of records.Example-Response is not sorted based on any attribute.
I have used xml datasource for both JDBC Step and Service Response but can't compare as the JDBC data source first record is different from Service Response Data source first record.I have to Iterate both the data sources.
Questions:-
1. Is the approach correct or is there any other better approach apart from xml data sources for JDBC and REST Step Response?
2. Is there any way to sort Data source values before comparison? If yes then provide information regarding same.
I am pretty much new to groovy and soapUI so please ignore my mistakes and let me know in case any other information is required?

Thanks,

3 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Your approach is correct. And for your scenario, I would still use XPATH. In XPATH you can look for specific XML node depending on the value.

    It would be worthwhile to find the correct expression to find your node. Here are some links that should help:
    http://www.w3schools.com/xpath/
    http://oreilly.com/perl/excerpts/system-admin-with-perl/ten-minute-xpath-utorial.html

    Also, you can provide and example of the XML your are trying to search through and explain which node you want to find.

    Thanks,
    Michael Giller
    SmartBear Software
  • I was able to Validate Service Response against JDBC successfully through Xpath Indeed.
    Final Project Structure looks like
    1. Service Request(It returns xml as Response)
    2. JDBC Request
    3. xml DataSource Step to Extract Parameters from JDBC Request
    4. Assertion Step with Xpath Match Step With Source as Service Request and Property as Response.
    5. DataSource Loop with Source as xml DataSource Step and Target as Assertion Step.
    The catch was to compare Xpath with Data Source Value ie. XPath with ${DataSource#Property}

    I am able to continue further and Appreciate your Response.
    Thanks,
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Great to hear tests are working! Thanks also for sharing the final test case structure.

    Thanks,
    Michael Giller
    SmartBear Software