Array as from JSON to XML in Assign Message Policy

Hi Everybody,

Need help.  The request is of JSON type shown below, it has an array called billNumbers which is dynamic (can have 0 or more bill numbers in it).

{
 
  "transactionSequenceId""TEST4323523",
  "mainDiscountPercentage"0,
  "interestDiscountPercentage"0,
  "fineDiscountPercentage"0,
  "sendFirstInstallmentEmail"false,
    "token""RkFMVkVT",
    "billNumbers": [
        { "billNumber""inv-123"},
        { "billNumber""inv-789"}
    ]
}
 
I have managed to extract the billNumbers Array using the Extract Variables policy as shown below in two ways:-
 
<JSONPayload>
<Variable name="billNumbers" type="array">
<JSONPath>$.billNumbers</JSONPath>
</Variable>

<Variable name="SList">
<JSONPath>$.billNumbers[*]</JSONPath>
</Variable>
</JSONPayload>
 
I need to further add this array in Assign Message policy of  SOAP XML to send it to the backend service which accepts soap xml type.
Like the parameter token is added this way --> <token>{token}</token>
 
But i dont understand how the same can be done for billNumbers array. Could anybody please tell me how I can do this? 
 
0 1 98
1 REPLY 1

Based on your description of the token example, it looks like you're hardcoding a templated XML response.. 

There's a JSON to XML policy for converting JSON to XML. You could reformat your json and use that policy. Or you could use JSON to XML and then an XSLT to change the XML structure if necessary.

https://cloud.google.com/apigee/docs/api-platform/reference/policies/json-xml-policy

https://cloud.google.com/apigee/docs/api-platform/reference/policies/xsl-transform-policy