Skip to Content

JSON to XML

Hi Experts,

I have a scenario like below:

SAP --> PI  --> 3rd party (REST )

Requirement is once thirdparty receives request from PI, it sends response(JSON message) in encrypted format.

I need to decrypt my response and againa want to convert that to xml and send back to SAP

For decrypting, i already have a java code.

Response Json strucutre looks:

For successful response:

[{

“serviceName” : ”xxxxx”,

“function” :  “aaaa”,

“responseStatus” : ”Success” ,

“errorMessages” : “”

“results” :

[{

  "Name":"xxxx",

  "SNO":"xxxx",

  "Type":"cccc",

  "TailNumber":"ccc",

  "RegNumber":"",

  "Fleet":"a12w"},

  

  ......

}]

For failed response :

[{

“serviceName” : ”xxxx”,

“function” :  “aaaa”,

“responseStatus” : ”failure” ,

“errorMessages” : “Reason for failure”

“results” : []

}]

I have 2 ideas:

1. write a module bean to decrypt and converto to xml

2. read response as a string and using java mapping, convert that to xml

I have little knoeledge on Java, so requesitng some experts help.

Regards,

SP

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Oct 15, 2015 at 02:50 PM

    Hi SP

    If you are using REST Adapter, then you have option in channel itself to convert json to xml.

    Since your response is decrypted, not sure it will work. But still you can give it a try.

    You can also check this module in the below link. This might be helpful to you.

    JSONTransformBean Part 1: Converting JSON content to XML

    check this also.

    Regards

    Osman

    Add comment
    10|10000 characters needed characters exceeded