Assign Message to Response - Error (Deletes the body)

Not applicable

I am looking to simply swamp out a variable in the Response - FormPara but it is replacing the entire body. In the AssignTo the type="response" so don't know where to go from here.

-------------------Policy------------------

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<AssignMessage name="Assign-Message-TransactionID-Response">

<AssignTo createNew="false" type="response"/>

<DisplayName>Assign Message-TransactionID-Response</DisplayName>

<Set>

<FormParams>

<FormParam name="TransactionID">{callDetails.TransactionID}</FormParam>

</FormParams>

</Set>

<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>

</AssignMessage>

----------------Response from Target Endpoint------------------------

<html>

<body onload='document.forms["form"].submit()'>

<form name='form' action='www.datastreamx.com' method='post'>

<input type='hidden' name='CustomerCode' value=''/>

<input type='hidden' name='MSISDN' value='919884xxxxx'/>

<input type='hidden' name='PlutoTxnID' value='0'/>

<input type='hidden' name='TransactionID' value='00009-123'/>

<input type='hidden' name='ARPU' value='794.62'/>

<input type='hidden' name='Error' value=''/>

</form>

</body>

</html>

----------------After Assign Message --- Body-----

TransactionID=00009

0 8 2,370
8 REPLIES 8

Dear @Mike Davie,

Above policy sets the formparam which is generally used in request. Ideally, you need to use extract variables policy to extract information from response.

If transaction id is already available as a flow variable & you would like to assign to new flow variable then you can use below tag in Assign Message Policy.

<AssignVariable>
    <Name>TransactionID</Name>
    <Ref>callDetails.TransactionID</Ref>
    <Value>ErrorOnCopy</Value>
</AssignVariable>

I looked at the Extract Variable Policy, but then I would require to reconstruct the entire Response, correct?

@Mike Davie , Do you have the transaction id already & trying to assign to a new variable ? What is the output you are expecting ? Are you trying to modify the response that will be sent to the client ? how does the variable {callDetails.TransactionID} getting populated ? Using Javascript policy ? Need more details to understand your issue.

callDetails.TransactionID comes from a Extract Variable Policy in the pre-flow. The output we are expect is the form response but with the callDetails.TransactionID (To replace the transactionID given)

The API call has "TransactionID" in the header... In the preflow, we take that TransactionID, then add a code to it. Example TransactionID=123, then we make it TransactionID=123-abc then send it to the Target Endpoint. (We do this successfully using Extract Variable).... Now in the Response... we want to replace the Response TransactionID (Which equal 123-ABC) with the Original TransactionID which we have stored in callDetails.TransactionID

One element I noticed which could be causing this problem. The response is text/html, but after I update in the AssignVariable my Content-Type Changes..... (Below from the Trace)

Content-Type
text/html; charset=utf-8application/x-www-form-urlencoded

This is probably the problem.. "Note: This option only works when the contentType of <AssignTo> element is application/x-www-form-urlencoded"

@Mike Davie ,

  • You can use javascript policy to extract the entire response & replace the original transaction id.
  • Assign the replaced payload to a variable using
var originalResponse = context.getVariable('response.content');

var updatedResponse = //Replace the string using javascript
context.setVariable('updatedResponse', updatedResponse);
  • Now use the Assign message policy to replace the payload,
<Set>     
    <Payload contentType="text/plain">{updatedResponse}</Payload>      
</Set>