REST Api Json Message format

Friends,

I have a requirement to convert a Json String to an Xml. Has anyone done this, or is there any built-in svc that could help.

The interface flow is to call an external rest API, get the reponse and update the DB tables. They only support Json responses but not xml, so i have to find a way to convert the response to xml and then map the fields.

Thanks everyone for your time.

S.

webMethods 8.2 release notes - from the mediator section!!!
"Support for JSON Content

Mediator can send and receive JSON content over REST or XML virtual services. Mediator can handle content mediation between JSON and XML. For example, a service consumer can send JSON content to a REST virtual service in Mediator. The virtual service can automatically convert the JSON content to XML and then forward the XML content to the native service and vice-versa."

Thank you. Never really worked with Mediator, I will check on this.

Thanks,
S

It means there is an additional license fee you will have to shell out for Mediator. If that is a limitation you might want to check out the JSON in Java resources and convert the JSON object to XML using a Java service. Use this service as a Framework on IS for converting JSON to XML.

[URL]http://www.json.org/java/[/URL]
[URL]http://www.json.org/javadoc/org/json/XML.html[/URL]

Cheers,
Akshith

I kinda figured that. I think the best is to build a java svc. Thanks for the links, appreciate it.

S.

Hi Smathangi,

Can you please shed some light on how you invoked the REST API from webMethods designer. I have a similar requirement but hasn’t worked on how to invoke a REST API.

What services we need to use to call a REST service and we want to get it in the form of application/json.

Thanks,
Kumar.

Hi Smathangi,

Can you please shed some light on how you invoked the REST API from webMethods designer. I have a similar requirement but hasn’t worked on how to invoke a REST API.

What services we need to use to call a REST service and we want to get it in the form of application/json.

Thanks,
Kumar.

Hello Smathangi,

I have given a try with sample JSON message to convert to XML format by making use of built in services. Hope it helps

pub.json:jsonStringToDocument
pub.xml:documentToXMLString

JSON String:

{“employees”:[
{“firstName”:“John”, “lastName”:“Doe”},
{“firstName”:“Anna”, “lastName”:“Smith”},
{“firstName”:“Peter”,“lastName”:“Jones”}
]}

XML Output:

<?xml version="1.0"?> John Doe Anna Smith Peter Jones

JSONstringtoXMLConversion.png