Data Source Correlation - Request Body

robbinsmkrobbinsmk Posts: 8

I am trying to use the Data Source Correlation Request body but the documentation in the help is limited and doesn't have any examples. Are there any examples on how I set up the xpath correctly for the JSON Request Body that the service is receiving? In my request I have three elements and I want to match on one of them and then in the Data Table the response will return with the rest of the data.

Comments

  • Ireneusz SzmigielIreneusz Szmigiel Posts: 198 ✭✭

    Hi robbinsmk

    in Virtualize User's manual you have whole section about it, see "Data Source Correlation Tab".
    The general idea is to select which column from data source should be used for corelation.
    Now if selected value from request ( by Xpath) is equal to value (particular row) from selected column then the rest of the row can be used to build response. You have to parametrize response with appropriate column names.

  • [Deleted User][Deleted User] Posts: 0

    Hi Robbinsmk,

    One easy step to miss is adding a sample request body to your JSON message responder before attempting to add data source correlation.

    To add a sample request, click on the "options" tab within your responder editor:

    Select "Request Template" on the left and then paste a sample JSON request into the "request message template for assisted XPath Creation" field:

    You can click the "tree" tab to make sure it parses correctly.

    Now that you've provided a sample request, you should be able to select the field(s) you want to use for data source correlation in the "Data Source Correlation" tab (if Add is grayed out, make sure you have added a data source already):

    How does this work? Well you can see in the screenshot above that I'm mapping a field in my incoming request to a column name in my data source (the column has the name "sampleID" in my example). Here is my data source:

    If the incoming request has a sampleID element with value 12345, then we correlate on row #3. If our response is parameterized against the "userName" field, then we will respond with the value "spencer"

  • [Deleted User][Deleted User] Posts: 0
    edited March 2017

    Let me know if you have any questions or issues.

  • gkburnsgkburns Posts: 8

    Is there any way to make the request body "xpath --> data source value" comparison be case insensitive? We have user ID stored in the repository in various upper/lower case combinations depending on how the traffic file recorded the request.

  • keegan_chankeegan_chan Posts: 56

    You can use Critical Expressions together with Java's pattern syntax to accomplish what need. Please see the documentation on Critical Expressions for details.

  • gkburnsgkburns Posts: 8

    Can you add a link to the documentation you're talking about? Multiple google searches produced nothing. Thanks

  • keegan_chankeegan_chan Posts: 56

    The best way is to go to Help Content of the desktop GUI and open the User Guide from there. The User Guide provides you with a textbox to search for topics within it.

  • OmarROmarR Posts: 213 admin

    In addition to using the "Help Content" in the GUI, you may also find our docs online at https://docs.parasoft.com/.

    Below is a link to documentation for "criteria expression syntax".

    https://docs.parasoft.com/display/SOAVIRT9105/Criteria+Expressions+for+Matching+Values+with+the+Message+Responder

  • gkburnsgkburns Posts: 8

    Thanks for this information. In the Data Source Correlation tab, Request Body XPath, I can indeed enter an expression in the XPath field, but that only changes how it locates the field name in the body of the request. I need to change the comparison between the value of the request field and the value of the database column field. Is there a way to do that?

  • OmarROmarR Posts: 213 admin

    You can try using the lower-case() xpath function to convert the request value to lowercase for data source correlation. Also, update your sql query to return the database value in lowercase.

    For example:

  • gkburnsgkburns Posts: 8

    Thanks, the lower-case() worked, but where can I change the sql query for a data repository database?

Sign In or Register to comment.