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.

using entire request body content for xpath correation

Options

Hello,
I am trying to use entire request body for xpath corration using the xpath expression:
/root = 'req body'
however, when sending actual requests, the responder is not matching. How do i make sure that despite variations in the request body in terms of lines or empty spaces, the responder matches based only on the structure and values of the json or xml body. THank you.

Answers

  • williammccusker
    williammccusker Posts: 718 ✭✭✭
    Options

    Hi,

    Are you saying you want to check that all values in the incoming request match? If you are looking for exact matches on entire messages then the Files Responder might be a better option since you can specify the exact request in a file paired with a response and all values in the incoming request will need to match the defined request.

  • alemayehu_bofa
    alemayehu_bofa Posts: 43 ✭
    edited September 30
    Options

    Hi William, I would like to use the entire request body (json or xml ) for request body correlation instead of values of individual elements. response will be matched if the request sent matches with that used in the xpath correlation. i used the xpath experssion /root = 'req body' but is not working when same req body is sent. THis is in the context of REST calls. In addtion to the request body, the request path and method are also checked.

  • williammccusker
    williammccusker Posts: 718 ✭✭✭
    Options

    Hi,

    If the issue is whitespace differences then that xpath would not normalize that. Since you want exact request matching I recommend looking at the Files Responder since it performs exact request matching and does have internal handling to do some whitespace normalization.

  • alemayehu_bofa
    Options

    thanks again. can the File Responder be used in the context of REST calls with request method and path?

  • williammccusker
    williammccusker Posts: 718 ✭✭✭
    Options

    Yes, it will match on request method and path. It can do exact path matching or have wild card matching if needed.

  • alemayehu_bofa
    Options

    ok, thanks.

  • alemayehu_bofa
    Options

    sorry one last question: is this feature exposed via the REST APIs ?

  • williammccusker
    williammccusker Posts: 718 ✭✭✭
    Options

    No, the Files Responder does not have REST APIs.

  • alemayehu_bofa
    Options

    since i would like to use REST API, i have resorted to the custom message responder correlation in which i can add a code to compare if two contents are same or not after parsing them into json or xml. Thanks for your help.