How to replace a value of the element in soap request in Api Connect using Gateway scripting

98 Views Asked by At

Below is input request that I have saved in the Request variable and saved the response string in the ResponseString variable. Now I need to replace the ResponseString variable value with Payload element value in the input request, please refer to the below request for reference. All helps are much appreciated!

var Request = apim.getvariable('originalRequest');

var ResponseString = 'DataIndex_12345';

Input Request:

<soap:Envelope xmlns:or="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <soap:Body>
      <or:Request>
         <Sender>Mark</Sender>
         <Receiver>Steve</Receiver>
         <Payload>Data</Payload>
      </or:Request>
   </soap:Body>
</soap:Envelope>

Expected Output Request:

<soap:Envelope xmlns:or="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <soap:Body>
      <or:Request>
         <Sender>Mark</Sender>
         <Receiver>Steve</Receiver>
         <Payload>DataIndex_12345</Payload>
      </or:Request>
   </soap:Body>
</soap:Envelope>
0

There are 0 best solutions below