Forum Discussion

Joppe's avatar
Joppe
New Contributor
16 years ago

Extract parts of response and use in other test step.

Hi!

I'm a newbie with soapIU and i have a question.

Is it possible to extract data from a response and use it in the next test step.

For instance, i do a request and get this response (part of it):

     
         a531df37-6a25-4bba-8d3a-a5c07d7d1dcf
     

   


Now i would like to extract the "SessionId" and use it in my next test step.

Is that possible?

Thanks!
Best regards

Joppe
  • anikiup's avatar
    anikiup
    New Contributor
    Its pretty easy. You dont have to write any code.
    Lets say, that example you gave, is teststep1.
    Now, in your teststep2, click on the field where you want your data to do, Get Data ->Teststep1 ->response > your value.
    something like this:
    ${teststep1 - Request 1#Response#/StateHeader/SessionsId}
  • Joppe's avatar
    Joppe
    New Contributor
    Great! Thats just what im looking for.
    But i cant get it to work, at least on my response.

    Here is the complete response:


     

         
            16cf4754-a628-4ef4-8fad-ce60b28ffdde
         

     

     
         
           
                998800
                380560593
                NISSE 3805605
                1417818155
                TESTMAN
               
                  0
                 
               

                380560593
           

         

     


    What i want to extrac it SessionId. Anyone who can help me?

    Thanks!
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Did you remember to include the namespace prefix (s:SessionId) ?
  • Joppe's avatar
    Joppe
    New Contributor
    Yes,  have tried several combinations.

    For example:
    ${GetCustomerSession - Request 1#Response#//* - This one returns the whole response.
    ${GetCustomerSession - Request 1#Response#//s:Envelope/s:Header/*} - returns the headerpart.
    ${GetCustomerSession - Request 1#Response#//s:Envelope/s:Header/s:Stateheader/*} - Nothing
    ${GetCustomerSession - Request 1#Response#//s:Envelope/s:Header/Stateheader/*} - Nothing
    ${GetCustomerSession - Request 1#Response#//s:Envelope/s:Header/s:SessionId} - Nothing
    ${GetCustomerSession - Request 1#Response#//s:Envelope/s:Header/SessionId} - Nothing

    Can it be the namespace in a namespace that could be the problem?
  • It could be a namespace issue, since the way you have defined the namespaces in the response means that StateHeader will have an unknown namespace when it is encountered. try either specifying the namespace explicitly in the response, or if you do not have access to the response, specifying it explicitly in the xpath.