camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@evosent.com>
Subject RE: Camel XmlJson Question
Date Fri, 31 Jul 2015 08:10:16 GMT
Hi,

Have you tried using the camel-xmljson data format instead of custom code?

Take a look at the link provided above.

Raúl.
On 31 Jul 2015 08:18, "srinit" <sree.tallapalli@gmail.com> wrote:

> I am trying to xml <==> json using following code
>
> @Override
>         public void xml2json(String xml) throws JSONException {
>                 JSONObject xmlJSONObj = XML.toJSONObject(xml);
>                 String jsonPrettyPrintString = xmlJSONObj
>                                 .toString(PRETTY_PRINT_INDENT_FACTOR);
>                 System.out.println(jsonPrettyPrintString);
>
>         }
>
>         @Override
>         public void json2xml(String json) throws JSONException {
>                 JSONObject jsonObject = new JSONObject(json);
>                 String xml = XML.toString(jsonObject);
>                 System.out.println(xml);
>         }
>
> For following SOAP message
>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>         <soap:Body>
>                 <ns2:helloWorld xmlns:ns2="
> http://service.ws.test.xxxx.com/">
>                         <arg0>John</arg0>
>                 </ns2:helloWorld>
>         </soap:Body>
> </soap:Envelope>
>
>
> After xml2json() the output is like
>
> {"soap:Envelope": {
>     "soap:Body": {"ns2:helloWorld": {
>         "arg0": "John",
>         "xmlns:ns2": "http://service.ws.test.xxxxx.com/"
>     }},
>     "xmlns:soap": "http://schemas.xmlsoap.org/soap/envelope/"
> }}
>
> And when convert this json with json2xml() the output is like this
>
> <soap:Envelope>
> <soap:Body>
> <ns2:helloWorld>
> <arg0>John</arg0>
> <xmlns:ns2>http://service.ws.test.xxxx.com/</xmlns:ns2>
> </ns2:helloWorld>
> </soap:Body>
> <xmlns:soap>http://schemas.xmlsoap.org/soap/envelope/</xmlns:soap>
> </soap:Envelope>
>
> Which is wrong SOAP message, here the namespace information is wrongly
> taken.
> I tried to see, whether json library have something to customize the
> parsing
> and found nothing.
> any help?
>
> Thanks
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-XmlJson-Question-tp5770021p5770099.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message