AnsweredAssumed Answered

replace the value in response in live invocation scenario

Question asked by CTS_LISA on Jan 13, 2017
Latest reply on Jan 26, 2017 by CTS_LISA

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,

Outcomes