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.

Reply via email to