You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nitn Gautam <ga...@gmail.com> on 2012/08/11 18:55:10 UTC

Camel Custom Data Format xmljson

I am trying to make a custom dataformat using xmljson. I want to support ":"
in marshall/UnMarshall process.
I am using Spring XML for route definition. Once I am done with this custom
format where to place that java class and what will be the syntax.

Current syntax

<xmljson id="xmljson"/>
    <xmljson id="xmljsonWithOptions" forceTopLevelObject="true"
trimSpaces="true" rootName="nits" skipNamespaces="true" 
             removeNamespacePrefixes="true" expandableProperties="d e"/>
<unmarshal ref="xmljsonWithOptions"/>
<marshal ref="xmljson"/>



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Data-Format-xmljson-tp5717159.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Custom Data Format xmljson

Posted by Henryk Konsek <he...@gmail.com>.
> BTW reading SOAP messages as JSON looks suspicious in the first place
> :) . SOAP is a transport envelope for the message, so it is usually
> created only for the time of web service communication. Do you really
> need to store SOAP messages somewhere in the JSON format? I'd rethink
> this approach from the architectural point of view :) .

Can't you just store the message itself (without SOAP stuff) as JSON
and then, generate SOAP envelope when you want to send it?

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Camel Custom Data Format xmljson

Posted by Henryk Konsek <he...@gmail.com>.
> Colon (:) support means, I am passing soap creation data in json to camel
> which I need to transform inside a soap xml which I am trying to achieve
> using xml2json library

Assuming that there is really no way of escaping colon in JSON keys...

Maybe instead of creating your own data format, you will just create
XML with your escaped colons (____) and then process the resulting XML
to replace the tokens? I would prefer to have such suspicious
processing explicitly defined in message transformation than hidden
behind the data format abstraction.

BTW reading SOAP messages as JSON looks suspicious in the first place
:) . SOAP is a transport envelope for the message, so it is usually
created only for the time of web service communication. Do you really
need to store SOAP messages somewhere in the JSON format? I'd rethink
this approach from the architectural point of view :) .

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Camel Custom Data Format xmljson

Posted by Nitin Gautam <ga...@gmail.com>.
Colon (:) support means, I am passing soap creation data in json to camel
which I need to transform inside a soap xml which I am trying to achieve
using xml2json library and execute

Sample JSON data want to convert in XML, I cann't pass colon directly as it
is reserved for JSON hence passing 4 underscore and want to convert during
unmarshal json to xml
{
 "soapenv____Header":"",
    "soapenv____Body": {
        "nits____GetList": {
            "nits____UserToken": {
                "nits____Username": "nits1234",
                "nits____Key": "2012-09-05 23:53:11:818115650956"
            },
            "nits____Type": "CATEGORY"
        }
    }
}

XML Ouput needed
<soapenv:Header>
..........
</soapenv:Header>



-----
Knowledge Is Power Share It
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Data-Format-xmljson-tp5717159p5717182.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Custom Data Format xmljson

Posted by Raul Kripalani <ra...@fusesource.com>.
Hi,

Could you clarify what you mean by supporting the colon character in
the marshal/unmarshal process?

The camel-xmljson delegates the actual marshalling and unmarshalling
to a library called json-lib.

Regards.

Sent from my iPhone

On 11 Aug 2012, at 17:55, Nitn Gautam <ga...@gmail.com> wrote:

> I am trying to make a custom dataformat using xmljson. I want to support ":"
> in marshall/UnMarshall process.
> I am using Spring XML for route definition. Once I am done with this custom
> format where to place that java class and what will be the syntax.
>
> Current syntax
>
> <xmljson id="xmljson"/>
>    <xmljson id="xmljsonWithOptions" forceTopLevelObject="true"
> trimSpaces="true" rootName="nits" skipNamespaces="true"
>             removeNamespacePrefixes="true" expandableProperties="d e"/>
> <unmarshal ref="xmljsonWithOptions"/>
> <marshal ref="xmljson"/>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Data-Format-xmljson-tp5717159.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Custom Data Format xmljson

Posted by Nitin Gautam <ga...@gmail.com>.
I am aware of this link but want to ask once i create a custom formatter
where to deplo that file so that can access inside camel context.

i am using camel inside karaf.



-----
Knowledge Is Power Share It
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Data-Format-xmljson-tp5717159p5717162.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Custom Data Format xmljson

Posted by Taariq Levack <ta...@gmail.com>.
Hi

Here's a nice page on custom data format[1]

[1]http://camel.apache.org/custom-dataformat.html

On 11 Aug 2012, at 18:55, Nitn Gautam <ga...@gmail.com> wrote:

> I am trying to make a custom dataformat using xmljson. I want to support ":"
> in marshall/UnMarshall process.
> I am using Spring XML for route definition. Once I am done with this custom
> format where to place that java class and what will be the syntax.
> 
> Current syntax
> 
> <xmljson id="xmljson"/>
>    <xmljson id="xmljsonWithOptions" forceTopLevelObject="true"
> trimSpaces="true" rootName="nits" skipNamespaces="true" 
>             removeNamespacePrefixes="true" expandableProperties="d e"/>
> <unmarshal ref="xmljsonWithOptions"/>
> <marshal ref="xmljson"/>
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Data-Format-xmljson-tp5717159.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Custom Data Format xmljson

Posted by Henryk Konsek <he...@gmail.com>.
Hi Nitn,

> I am running Camel inside Karaf. I have created a custom dataformat by
> implementing DataFormat interface. Now I have my custom class.

Just put your data format related classes (and other resources if
needed) into the same OSGI jar in which is your route.

If you want to share your data format between multiple OSGI modules
(in Karaf for example):
- put data format into separated OSGI module
- build module and deploy jar into Karaf
- use data format module as a dependency in your routing module


Regarding the usage of the data format in the route:

// You can use it directly
from("...").marshal(new MyDataFormat())...
// Or via registry
from("...").marshal("myDataFormatDefinedInSpring")...


BTW Raul asked a good question - what do you mean by using colon?

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Camel Custom Data Format xmljson

Posted by James Carman <ja...@carmanconsulting.com>.
Take a look at what camel-jaxb does:

http://svn.apache.org/repos/asf/camel/trunk/components/camel-jaxb/src/main/resources/META-INF/services/org/apache/camel/dataformat/jaxb

You need to do something similar.  This is the class that will look
for that file in an OSGi environment:

http://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java

On Sun, Aug 12, 2012 at 1:35 AM, Nitin Gautam <ga...@gmail.com> wrote:
> I am running Camel inside Karaf. I have created a custom dataformat by
> implementing DataFormat interface. Now I have my custom class.
>
> In order to make it visible to my camel route inside karaf where to copy
> this class file?
>
> Please provide guidance.
>
>
>
>
> -----
> Knowledge Is Power Share It
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Data-Format-xmljson-tp5717159p5717163.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Custom Data Format xmljson

Posted by Nitin Gautam <ga...@gmail.com>.
I am running Camel inside Karaf. I have created a custom dataformat by
implementing DataFormat interface. Now I have my custom class.

In order to make it visible to my camel route inside karaf where to copy
this class file?

Please provide guidance.




-----
Knowledge Is Power Share It
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Data-Format-xmljson-tp5717159p5717163.html
Sent from the Camel - Users mailing list archive at Nabble.com.