Hi,
I need one quick help in replacing some of the xml elements values from response.
Scenario: I need to invoke live service in my model, capture the response, based on the value of xml element “A”, I need to replace the value of element “B”, and then send the response.
What I did: I captured the live response, since response comes in a responsee list, I got the response body as text by- response = response.getBodyText()
Now I can access the response body as text. I am able to send the response back as transient response.
Issue: before sending response, based on the value of xml element “A”, I need to replace the value of element “B”, and then send the response. I am trying to use xpath and not getting the replacement. Not sure if regular expression will help me.
Ex: in following response body
</PRegistration>
<Registration>
<Status />
<Type>
<code>500000</code>
<description>my no</description>
</Type>
<Number>900</Number>
<Identification>
<Name>Obj</Name>
………
If value of <code> is 500000 then replace the value of <Number> with “abc”
Please guide me how to achieve this.
Thanks,
Thanks Prema and Joel.
My solution required to modify the values in response and not in the request and the solution in the post Modify argument values in request to send in LIVE SYSTEM/Image Validation mode?
talk about the "modification in request arguments"
Response arguments are not available explicitly, that's the reason it can't be modify straight away. I tried to write Beanshell script and use regex to find the value, match and replace the same.
I am done with the solution and it is working as expected.
Thanks for all the help.
Regards,
Ritu