Does api gateway transformation support xml functions like util.parseXml?

0

Hi,

We have a soap service which takes xml request. We want to make json request available for our clients. The idea is that the clients sends json request to api gateway and then we will transform(using vtl scripting) the request to xml and send it so our web service(soap) and then do the same when we receive the response.

The issue we are having is, it seems like functions like "util.parseXml" is not working . Although aws does specify that it works when using it in AWS App Sync but i could not find any documentation that shows it works in api gateway.

Thanks

Petervd
gefragt vor 3 Monaten108 Aufrufe
1 Antwort
1

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.

profile picture
EXPERTE
beantwortet vor 3 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen