Skip to Content
avatar image
Former Member

JSON to XML conversion in receiver REST communication channel

Hi Experts,

I am currently working on a Proxy to REST (synchronous) scenario, and have used SAP's REST adapter in the receiver communication channel.

I am using the GET operation here on the 'Waste-streams' resource of the target system's REST API, and am trying to retrieve all the Waste Streams for which the ChapterCode field is '01'.

This REST service of the target's system seems to be accepting the source message in XML format, but sends back a response message in the JSON format only. Hence I need to convert this JSON response into an XML structure that would match the response data type that I have created in the ESR. However, in this JSON to XML conversion, I am getting the following error:

com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.adapter.rest.ejb.json.ConverterException: Error validating JSON input at com.sap.aii.af.app.listener.AFWListenerBean.onMessage

A JSONObject text must begin with '{' at character 1 of [{"ChapterCode":"01","Description":"wastes resulting from exploration,mining,quarrying,and physical and chemical treatment of minerals","StreamCode":"","SubChapterCode":""},{.... (followed by the entire JSON payload that the REST service sends back.

Below are the details that I have used in the Data Format tab of my receiver communication channel:

Here, 'Response' is the root node of the Message type created in the ESR to accept the response message that the service sends back.

Please can someone help me out in resolving this issue.

Regards,

Jyotika.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 01, 2015 at 12:20 PM

    Hi all,

    I think for the benefit of the community someone should raise this problem to SAP in order to know if the JSON array is really not supported by Rest adapter or if they are thinking for example to include a new box to set the XML root tag manually for these cases.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Jyotika

      As your system is on a higher SP than mine (7.4 SP08), I think it should not be an issue to just deploy the EAR file directly.

      You don't need the zip and tar.gz files for deployment. Just the EAR will be sufficient, and yes, it's okay for Basis to deploy it. Former Member managed to deploy it on his system but not sure if he recompiled everything or just used the EAR file directly.

      As for communications, I'd prefer to keep it within SCN. If you want to, you can follow me and we can communicate via SCN Direct Message.

      Rgds

      Eng Swee

  • Mar 30, 2015 at 11:58 AM

    Hi Jyotika,

    You JSON structure is wrong, could share it?, in this way we can check where the problem can be.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Eng Swee Yeoh


      Thanks Inaki and Eng Swee for your response.

      I will check with the third party service provider if they can re structure the response message such that it starts with the JSON Object instead of JSON Array.

      Will get back to you in case I need more help.

      Thanks,

      Jyotika.