- Newest
- Most votes
- Most comments
To transform JSON requests to XML for your SOAP service using API Gateway, you can use VTL scripts in the integration request and response templates.
In the integration request template, use the util.parseJson() function to parse the JSON body and store it as a variable:
#set($input = $util.parseJson($input.body)) Then use util.toXml() to convert the JSON to XML:
$util.toXml($input) In the integration response template, parse the XML response body and convert it back to JSON:
#set($input = $util.parseXml($input.body)) $util.toJson($input) You may need to define mappings between JSON and XML properties as needed.
The VTL functions like util.parseJson() and util.toXml() work in API Gateway for transforming request and response payloads between formats.
Relevant content
- asked 7 months ago
- asked 2 years ago
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago