Forum Discussion

rajeshbachani's avatar
rajeshbachani
Occasional Contributor
14 years ago

Using entire SOAP response directly into a new SOAP request

Hi folks!

Am a newbie here, so please bear if the question is not new and has been asked and solved before.

A simple scenario in which we receive a SOAP response - and would like to use the exactly same SOAP message as a request for another webservice, with some changes in certain fields. Is this achievable with SOAP UI and groovy scripts together?

Currently, we have predefined SOAP requests for all the test cases, and are modifying the necessary fields from the response received prior to sending this request, using groovy scripts.

Any help in this matter would be appreciable!

Thanks,
Rajesh.

6 Replies

  • Hi welcome to the forum!

    Sorry but I don't understand. After reading your scenario I thought I understood, but then you say you are currently modifying fields using groovy scripts. Isn't that exactly what your question was asking?
  • rajeshbachani's avatar
    rajeshbachani
    Occasional Contributor
    Hello Unhandled!
    Thanks for your reply.

    I am sorry for not being very clear in the first post. But I will try to clarify the question here..

    So, we have an XML element which contains child elements. Say it is of the form: <device><id1>1</id1><id2>1</id2><id3>1</id3></device>

    And this is received as part of a SOAP Response A.

    We want to create a SOAP Request B, in which this XML element <device> needs to be directly used with the child nodes.

    Now two things can be done:

    1. A property transfer directly from Response A to Request B. This works fine.

    2. Saving the <device> into a Project property and retrieving that to fill up the <device> in Request B. This does not work. What is the problem in this? The problem is that when the transfer is done - the <device> element is filled with the value of the Project property - but also prepended with <CDATA> tags. Making the entire Request B to fail since it's not a valid tag.

    We want to use the 2nd solution - as it makes it more flexible to reuse the property value holding <device/> at any later time, and from any test suite within the project.


    On what I said regarding that we are using groovy scripts currently. Yes we are using that - but to do a property transfer for an atomic element in XML (one which does not have any children nodes). In such cases, when we save the value of the atomic element as a property on project level, and try to feed this into a request, it happens fine - without any CDATA. But the downside of this is that if the XML is huge, we will have to transfer all the values one by one, and also have one project-level property for each XML element. This is a lot of work. So, the goal is to be able to transfer the entire <device/> element into project-level property and be able to reuse it anywhere and anytime.

    Do you understand the question and the problem now? I sure realize that I have much more information now, but I have been playing with these things since a week now - on and off - but still this CDATA thing is really restricting our ability to reuse values at the project level.

    I will appreciate if you come back with some suggestions.

    Thanks,
    Raj.
  • Thanks for the details. I think I understand now.

    I am unable to reproduce this issue where data transferred from Response to Project property is enclosed with CDATA tags. Unfortunately, I don't have much experience with transferring XML nodes with child nodes in and out of properties.

    What version of soapUI are you using? Is is Pro or Free version?

    Have a look at this page to see if anything here is helpful for your scenario:
    http://www.soapui.org/Functional-Testin ... cdata.html - especially the section titled "Property Transfers and CDATA"
  • rajeshbachani's avatar
    rajeshbachani
    Occasional Contributor
    Thanks.
    I think you can reproduce it only if you go a step further, and actually transfer the property value to the request. Only then am I able to see this CDATA tags being inserted - as somehow this entire value is considered to be a string I guess, instead of an XML node.

    The value of the project property is as expected

    I have already referred to this page several times. Also that I am not using the Pro version.

    Raj.
  • Also, just an FYI...
    Are you aware that the Property Transfer step is able to do what you want? It can transfer all the child nodes of one parent node in a Response inside a node of a Request. But this is just a one time thing. I understand you want to store the XML and use it many times from any test case.

    See this post for details
    http://www.soapui.org/forum/viewtopic.php?t=6371
  • rajeshbachani's avatar
    rajeshbachani
    Occasional Contributor
    Oh yeah sure! As I mentioned before - I was doing the transfer directly from the response to the request. But in that case, one has to use it within the same test suite! Which is kind of restricting me to make more reusable test cases within a test suite.

    Right now I am trying to see if a groovy script could parse the entire request (before it is submitted of course) and do some string manipulation on it and remove CDATA altogether.

    Do you know if anything of that kind can be done?

    Thanks,
    Raj.