cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Contributor

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-ReadyA...

 

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

If my answer helped you out, please consider leaving kudos and/or accepting as a solution.
Have an awesome day!
1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Sharing is caring - how to modify xml files using ReadyApi

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!


If my answer helped please click on the 'Accept as Solution' button.
4 REPLIES 4
Community Hero

Re: Sharing is caring - how to modify xml files using ReadyApi

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!


If my answer helped please click on the 'Accept as Solution' button.
Contributor

Re: Sharing is caring - how to modify xml files using ReadyApi

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

If my answer helped you out, please consider leaving kudos and/or accepting as a solution.
Have an awesome day!
Community Hero

Re: Sharing is caring - how to modify xml files using ReadyApi

Yes precisely that was my point.

 



If my answer helped please click on the 'Accept as Solution' button.
Contributor

Re: Sharing is caring - how to modify xml files using ReadyApi

Thanks, I'll definitely try that out!

If my answer helped you out, please consider leaving kudos and/or accepting as a solution.
Have an awesome day!
New Here?
Join us and watch the welcome video:
SeptemberNews
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win