Forum Discussion

Katarzyna's avatar
Katarzyna
Contributor
13 years ago

How can I use data from response to next request

I send SOAP request, and get response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SaveCreditCardResponse xmlns="http://x">
<SaveCreditCardResult>
<ID>10</ID>
</SaveCreditCardResult>
</SaveCreditCardResponse>
</soap:Body>
</soap:Envelope>

I would like to use this ID in next request - how can I do this?

10 Replies

  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Hi Katarzyna,

    You can use a Property Transfer TestStep after the SOAP response, and before the next SOAP request.

    Use the XPath expression "//id" in the Source pane to isolate the ID value.
    You'll need to specify an XPath express to replace the Target XML also.

    Have a read of http://www.soapui.org/Functional-Testin ... alues.html

    Kind regards,
    Tim
  • Hi,

    I try to do this, but I always get null. Maybe I do something wrong? Can ypu look at this?

    Best regards
    Katarzyna
  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Hi Katarzyna,

    Are there multiple elements of SaveCreditCardResponse, or is there (always) just the one? If so, why not use just "//id" as the XPath expression for the source?

    I've run into problems before using namespace declarations. It's hard to know exactly what's going wrong for you without seeing the full request & response messages, but I suspect it has something to do with the XPath expression not being deemed valid by SoapUI (because of the namespace prefix) - even if it appears to be valid, and is accepted by external tools (e.g. XMLSpy).

    Kind regards,
    Tim
  • Hi,
    This is whole response:

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <SaveCreditCardResponse xmlns="http://www.ibe.voyager.rsd.de-v1">
    <SaveCreditCardResult>
    <ID>20</ID>
    </SaveCreditCardResult>
    </SaveCreditCardResponse>
    </soap:Body>
    </soap:Envelope>


    I get only one ID, but when I reduce it to//ID - I still get Transferred Values: [null].

    Best Regards
    Katarzyna
  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Try this in your Source:

    //*[local-name()='ID']

    Also, ensure you have checked 'Transfer text content' in the properties (below the Target section).

    Kind regards,
    Tim
  • Hello,

    I works correctly - thanks a lot for your help.
    Unfortunately I have one more questions:

    1. How can I use this when I have more than one ID, for egazmple, when I have something like this:

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <SaveCreditCardResponse xmlns="http://www.ibe.voyager.rsd.de-v1">
    <SaveCreditCardResult>
    <ID>20</ID>
    </SaveCreditCardResult>
    <SaveBankResult>
    <ID>20</ID>
    </SaveBankResult>
    </SaveCreditCardResponse>
    </soap:Body>
    </soap:Envelope>


    I assume that local-name() does not work here.

    Best Regards
    Katarzyna
  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Hi Katarzyna,

    To isolate a particular item, try this (replacing the number accordingly):

    (//*[local-name() = 'ID'])[1]


    Kind regards,
    Tim
  • Hi,

    It works great - once again - thank you for your help.

    Best regards
    Katarzyna
  • kizna123's avatar
    kizna123
    New Contributor
    Hi,

    Can someone help me more on using Propery Transfer Step.
    I have a testStep1 which when I executed will get a NotificationId in the response.
    Now this Id changes everytime I run the test step, so everytime it changes I need the new Id to be inputed in the test step2 where it uses this Id to give more details about this Id.
    I dont have a pro or else I could have just said a right click & said Get Data from the testStep1.
    I did go through the responses but I am not able to understand as to what Source should be & what the Target should be..
    Please help me with this..