You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by helander <le...@gmail.com> on 2013/02/03 16:17:09 UTC

"Dynamic" data format in route

I have a route that creates Soap requests/responses using camel-soap.

The route should handle arbitrary soap services which means that I can not
define the "dataFormat" when the route is built. As of now, I create the
"dataFormat" in a processor and put it into an exchange property. My idea
was to be able to reference the "dataFormat" from the exchange in my
"marshal()" and "unmarshal()" steps in the route, but I can not figure out
the syntax to do that, can anyone help? If this is not possible, can  do the
marshal/unmarshal directly in a processor? If so, what is the syntax?


from("....").processor(....).marshal(....).to("service
endpoint").unmarshal(...);


Thanks

Lars



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-data-format-in-route-tp5726853.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: "Dynamic" data format in route

Posted by "web_nabble@sunilsamuel.com" <we...@sunilsamuel.com>.
Hello, 

I wanted to provide a solution for anyone else who may have the same
questions.  I also had a similar requirement where I create several data
formats via blueprint but I wanted a way for the route to determine which
data format to use.  That is, use a property value to determine the data
format name.  There is a component named "dataformat:" which is not
documented very well.  I was able to use the 'recipientList' and dataformat
component to do this as follows:

from("direct-vm:moxy-marshal")
	.choice()
	.when(simple("${property.moxyDataFormat} == null"))
		.throwException(new ExpressionIllegalSyntaxException("no property"))
	.otherwise()
		.recipientList(simple("dataformat:${property.moxyDataFormat}:marshal"))
;

from("direct-vm:moxy-unmarshal")
	.choice()
	.when(simple("${property.moxyDataFormat} == null"))
		.throwException(new ExpressionIllegalSyntaxException("no property"))
	.otherwise()
		.recipientList(simple("dataformat:${property.moxyDataFormat}:unmarshal"))
;




--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-data-format-in-route-tp5726853p5776681.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: "Dynamic" data format in route

Posted by Lars-Erik Helander <le...@gmail.com>.
Ok, thanks for the info

Skickat från min iPhone

4 feb 2013 kl. 09:19 skrev Claus Ibsen <cl...@gmail.com>:

> On Sun, Feb 3, 2013 at 4:17 PM, helander <le...@gmail.com> wrote:
>> I have a route that creates Soap requests/responses using camel-soap.
>> 
>> The route should handle arbitrary soap services which means that I can not
>> define the "dataFormat" when the route is built. As of now, I create the
>> "dataFormat" in a processor and put it into an exchange property. My idea
>> was to be able to reference the "dataFormat" from the exchange in my
>> "marshal()" and "unmarshal()" steps in the route, but I can not figure out
>> the syntax to do that, can anyone help? If this is not possible, can  do the
>> marshal/unmarshal directly in a processor? If so, what is the syntax?
>> 
>> 
>> from("....").processor(....).marshal(....).to("service
>> endpoint").unmarshal(...);
> 
> You cannot do this.
> 
> Data-Formats is not as flexible as endpoint uris are.
> 
> 
> You can use a POJO where you can do your dynamic marshal / unmarshal
> from Java code.
> 
> 
> 
>> 
>> Thanks
>> 
>> Lars
>> 
>> 
>> 
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-data-format-in-route-tp5726853.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen

Re: "Dynamic" data format in route

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Feb 3, 2013 at 4:17 PM, helander <le...@gmail.com> wrote:
> I have a route that creates Soap requests/responses using camel-soap.
>
> The route should handle arbitrary soap services which means that I can not
> define the "dataFormat" when the route is built. As of now, I create the
> "dataFormat" in a processor and put it into an exchange property. My idea
> was to be able to reference the "dataFormat" from the exchange in my
> "marshal()" and "unmarshal()" steps in the route, but I can not figure out
> the syntax to do that, can anyone help? If this is not possible, can  do the
> marshal/unmarshal directly in a processor? If so, what is the syntax?
>
>
> from("....").processor(....).marshal(....).to("service
> endpoint").unmarshal(...);
>

You cannot do this.

Data-Formats is not as flexible as endpoint uris are.


You can use a POJO where you can do your dynamic marshal / unmarshal
from Java code.



>
> Thanks
>
> Lars
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-data-format-in-route-tp5726853.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: "Dynamic" data format in route

Posted by Lars-Erik Helander <le...@gmail.com>.
No, its not a question about selecting variants of a specific dataformat, using totally different dataformats.

Thanks
Lars

Skickat från min iPhone

4 feb 2013 kl. 04:27 skrev Willem jiang <wi...@gmail.com>:

> Do you means you want to control the data format (soap 11 or soap 12) dynamically?
> I just checked the code of SOAP data format, it doesn't suppose to change the data format dynamically.
> But I think it is simple to work around it by use the CBR[1] which can check the message header of exchange property to route the message to the right route which is set with the right data formate.
> 
> [1]http://camel.apache.org/content-based-router.html  
> 
> --  
> Willem Jiang
> 
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang  
> Weibo: 姜宁willem
> 
> 
> 
> 
> On Sunday, February 3, 2013 at 11:17 PM, helander wrote:
> 
>> I have a route that creates Soap requests/responses using camel-soap.
>> 
>> The route should handle arbitrary soap services which means that I can not
>> define the "dataFormat" when the route is built. As of now, I create the
>> "dataFormat" in a processor and put it into an exchange property. My idea
>> was to be able to reference the "dataFormat" from the exchange in my
>> "marshal()" and "unmarshal()" steps in the route, but I can not figure out
>> the syntax to do that, can anyone help? If this is not possible, can do the
>> marshal/unmarshal directly in a processor? If so, what is the syntax?
>> 
>> 
>> from("....").processor(....).marshal(....).to("service
>> endpoint").unmarshal(...);
>> 
>> 
>> Thanks
>> 
>> Lars
>> 
>> 
>> 
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-data-format-in-route-tp5726853.html
>> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
> 
> 
> 

Re: "Dynamic" data format in route

Posted by Willem jiang <wi...@gmail.com>.
Do you means you want to control the data format (soap 11 or soap 12) dynamically?
I just checked the code of SOAP data format, it doesn't suppose to change the data format dynamically.
But I think it is simple to work around it by use the CBR[1] which can check the message header of exchange property to route the message to the right route which is set with the right data formate.

[1]http://camel.apache.org/content-based-router.html  

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem




On Sunday, February 3, 2013 at 11:17 PM, helander wrote:

> I have a route that creates Soap requests/responses using camel-soap.
>  
> The route should handle arbitrary soap services which means that I can not
> define the "dataFormat" when the route is built. As of now, I create the
> "dataFormat" in a processor and put it into an exchange property. My idea
> was to be able to reference the "dataFormat" from the exchange in my
> "marshal()" and "unmarshal()" steps in the route, but I can not figure out
> the syntax to do that, can anyone help? If this is not possible, can do the
> marshal/unmarshal directly in a processor? If so, what is the syntax?
>  
>  
> from("....").processor(....).marshal(....).to("service
> endpoint").unmarshal(...);
>  
>  
> Thanks
>  
> Lars
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-data-format-in-route-tp5726853.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).