The challenge with generic XML/JSON translation is there are corner cases where additional “hints” are needed. For example, consider the following:
{
"foos" : [
{
"prop1":"value1",
"prop2":"value2"
},
{
"prop1":"value3",
"prop2":"value4"
}
]
}
Convert that to XML you get:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<foos>
<prop1>value1</prop1>
<prop2>value2</prop2>
</foos>
<foos>
<prop1>value3</prop1>
<prop2>value4</prop2>
</foos>
</root>
No problem so far. And the reverse is not a problem either – as long as there are miultiple present. If there is only one, then the generic translation from XML to JSON would end up like this – no array:
{
"foos" :
{
"prop1":"value1",
"prop2":"value2"
}
}
When the Gateway hosts a SOAP interface, there is an option to expose that as a so-called “REST transformation.” It works okay, just be aware of the limitation. And unfortunately, I don’t think there is an option for the reverse – a REST API with a “SOAP transformation” option isn’t there.
What we do in this case is route things through Integration Server. Similar to what @DINESH_J suggests using request/response transformation policies, but instead use an IS service as the native endpoint instead of the “real” endpoint. Have it do the translation using document types, which provides the necessary “hints” when needed. Then have IS interact with the endpoint that would have been configured as the native endpoint in the API policy.
HTH
#API-Gateway#API-Management#webMethods