Forum Discussion

JMcKinley's avatar
JMcKinley
Contributor
16 years ago

Grabbing a response from SOAPUI Pro # 2

Previously, I posted a question about evaluating data in a response... an XPath assertion associated with the request works great...

Now, I have an additional complication:

The response I need to evaluate has repeating pairs of data... For example:

Lets say, we have two fields - one called text and the other called desc... the response might have:

id = 1
Text = "123"
desc = "ABC"

id = 2
Text = "456"
desc= "XYZ"

I just entered the data associated with id 2 but the response contains the data associated with id 1 and 2

I want to evaluate that Text = "456" has a description of "XYZ". Is there a way to evaluate that 456 is associated with XYZ using an assertion associated with the request?

I hope this makes sense 

Thanks!
Jim

5 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Jim,

    this should be possible in XPath, can you show the exact XML so I can suggest a solution?

    regards,

    /Ole
    eviware.com
  • I thought I had figured it out but now, there has been an added bit of complexity... here is XML from an example response:


       
         
             
                This is a test response 1
                This is a test name 1
             

             
                This is the test response 2
                This is the test name 2
             

             
                This is the test response 3
                This is the test name 3
             

         

       


    Here is the added complexity:

    The order of the response might change... The key and name will stay paired together as above but the order might change... the next time the response comes back, it might look like this:

       
       
         
             
                This is a test response 3
                This is a test name 3
             

             
                This is the test response 1
                This is the test name 1
             

             
                This is the test response 2
                This is the test name 2
             

         

       
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Jim,

    try the following XPath to validate that two key/name values are paired together:

    xpath:

    //key[../name='This is a test name 3']


    expected content

    This is a test response 3


    Does that work ok?

    regards!

    /Ole
    eviware.com
  • That works great!

    However, let's say we have more than a pair... for example:


       
         
             
                This is a test response 1
                This is a test name 1
               false
             

         
                This is a test response 1
                This is a test name 2
              true
           

             
                This is the test response 2
                This is the test name 2
                true
             

             
                This is the test response 3
                This is the test name 3
               true
             

         

       


    I tried a couple options but got syntax errors.... any suggestions to expand the XPath to morethan a pair of data?

    Sorry, I should have given this example as well.

    Thanks!!
  • Nevermind, I just figured out how to add more... using the and statement.

    Thanks for all your help again!!!