Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Data Source Correlation - Request Body

robbinsmk
robbinsmk 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 Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭

    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.

  • gkburns
    gkburns 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_chan
    keegan_chan Posts: 59 ✭✭

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

  • gkburns
    gkburns Posts: 8

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

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    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.

  • OmarR
    OmarR Posts: 233 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

  • gkburns
    gkburns 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?

  • OmarR
    OmarR Posts: 233 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:

  • gkburns
    gkburns Posts: 8

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