jsonxmlrestbpelopen-esb

How to pass JSON in Open ESB


I am creating a simple OpenESB application. On left I have a rest inbound partner link and on the right I am calling a rest outbound partner link. I am trying to pass json to the service but openESB automatically parses it and converts it into XML.

So the question is how do I stop open esb from converting the json string into xml since the service doesn't accept xml input.


Solution

  • OpenESB can process XML only.

    For consume-types=[ "application/json" ] JSON input is automatically converted into XML for further processing and invoke any external partner links if required.

    For produce-types=[ "application/json" ] XML data is converted into JSON by OpenESB.

    To achieve the same your JSON has to be in a format that when converted to XML, produces valid XML. For example, {"name":äbc"} looks like <name>abc</name> when converted to XML.

    JSON input like,

    {
        "name1":äbc",
        "name2":äbc"
    }
    

    looks like

    <name1>abc</name1>
    <name2>abc</name2>
    

    Now name1 and name2 XML elements does not have root element so OpenESB can not process it.

    If you give JSON input as

    {
         "someRootElement":{
             "name1":äbc",
             "name2":äbc"
          }
    }
    

    , converted XML would be like,

    <someRootElement>
       <name1>abc</name1>
       <name2>abc</name2>
    </someRootElement>
    

    This should work in your case. :)