Forum Discussion

MoUddin's avatar
MoUddin
Contributor
6 years ago
Solved

Could the static xml forms be edited through groovy within the response script?

Based on the examples, posted here:

https://community.smartbear.com/t5/SoapUI-Pro/Sharing-is-caring-how-to-modify-xml-files-using-ReadyApi/m-p/168661

 

Do you think this would be possible without a physical file?

ie in the ServiceV scenario, could the static xml forms be edited through groovy within the response script?

 

Sorry for stacking the questions, but would this need to be achieved through XmlSlurper on

requestContext.mockResponse.responseContent

or something like that?

 

My final question is how would I then save the changes to the edited response to send back through the virt? - I assume .responseContent only returns an instance of the response and does not allow you to edit the actual response itself.

 

Thanks in advance,

Mo

  • Ok so first you definitely can edit xml strings using the same code I posted above. I think you need to use the method 'parseText()' instead of 'parse' though...

    As for the other question... you can save the edited xml into a property and then use that value. I also wrote some article about properties few days ago.

    I'm on the phone right now but let me know if you need more help!

4 Replies

  • Lucian's avatar
    Lucian
    Community Hero
    Ok so first you definitely can edit xml strings using the same code I posted above. I think you need to use the method 'parseText()' instead of 'parse' though...

    As for the other question... you can save the edited xml into a property and then use that value. I also wrote some article about properties few days ago.

    I'm on the phone right now but let me know if you need more help!
    • MoUddin's avatar
      MoUddin
      Contributor

      So would it be best to have the intial response as

      <soap:Envelope namespacing="namespace declaration">
         <soap:Body>
            ${#MockService#property}
         </soap:Body>
      </soap:Envelope>

      pull this in and then create the contents, storing the result as a string 

      requestContext.mockService.setPropertyValue('property',<generated xml form as string>)

      Thanks in advance,

      Mo

      • Lucian's avatar
        Lucian
        Community Hero

        Yes precisely that was my point.