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/01/05 11:51:46 UTC

Producing/consuming SOAP messages to/from POJOs using camel-cxf

I am using camel-cxf for calling a web service. I am using a producer
template to create an exchange that has an in message that "contains" the
web service call details (input parameters as POJOs, operation name, ). The
exchange is sent to a route that looks as:

   from("direct:xyz").to("cxf:http://......");

This works very well and the service is properly called, but what if I
wanted to do some processing in the route of the generated SOAP messages and
not having the service called, how would I do then? 

Thanks

Lars

 



--
View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by helander <le...@gmail.com>.
I have now changed my client to be a JaxWS Proxy and this works fine, however
the cxf client proxy injects XML messages into the route (sends to the camel
context over a cxf bus). Can I somehow have the client send it as POJOs
instead, so that I can process the POJOs in the route before sending them to
the cxf bean?

Two related questions, probably more suited for the cxf user list but since
we are on a related subject ;) :

- Are the cxf JaxWS Proxies thread safe?
- Do I need to consider the construction time for the said proxies? Is it
realistic to create a new one upon each request, or is there a risk that it
will give me performance problems? I know that this will depend on my
performance requirements etc, but if anyone has some knowledge to share on
the subject I would happily receive it.

Thanks

Lars



--
View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5725653.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by helander <le...@gmail.com>.
Willem, thanks for the clarification.

Lars



--
View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5725028.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by Willem jiang <wi...@gmail.com>.
If you want to send the message smartly, you can do the work like this

form("direct:logical").to("cxf:bean:clientEndpoint");

from("direct:physical").to("……")

You can specify the clientEndpoint Address to be "camel://direct:physical", then the second camel route can route the request dynamically as you want.
You can change the invocation parameters in the first route as usual.


--  
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 Monday, January 7, 2013 at 4:11 AM, helander wrote:

> Do you mean something like this:
>  
> from("cxf:bean:nameofendpointbean").to(......
>  
> What address do I put on the endpoint bean ?
>  
> What adress do I specify in the cxf client ?
>  
> Thanks
>  
> Lars
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5725019.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by helander <le...@gmail.com>.
Do you mean something like this:

    from("cxf:bean:nameofendpointbean").to(......

What address do I put on the endpoint bean ?

What adress do I specify in the cxf client ?

Thanks

Lars



--
View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5725019.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by Willem jiang <wi...@gmail.com>.
CXF transport just handle the message as Stream, if you want to use POJO data format s the camel-cxf does. You can configure the cxfEndpoint to use the camel transport.

Then you may need to define two camel route , one is for the logical view(marshaling and unmarshaling the SOAP message), the other is used for the physical view (transport level, sending or receiving the Stream).

--  
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, January 6, 2013 at 7:06 PM, helander wrote:

> Hi Willem,
>  
> that helped a lot. I am now getting the request message to the route that
> receives the request from the cxf client. It is of type java.IO.InputStream,
> how do I make it into a structure where I can read the xml elements, i.e.
> similar to PAYLOAD format? Can I convert it back to POJO (not sure I need
> this, just curious in case I would need it)?
>  
> Thanks
>  
> Lars
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5724985.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
>  




Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by helander <le...@gmail.com>.
Hi Willem,

that helped a lot. I am now getting the request message to the route that
receives the request from the cxf client. It is of type java.IO.InputStream,
how do I make it into a structure where I can read the xml elements, i.e.
similar to PAYLOAD format? Can I convert it back to POJO (not sure I need
this, just curious in case I would need it)?

Thanks

Lars



--
View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5724985.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by Willem jiang <wi...@gmail.com>.
Here is some unit tests[1][2][3] those you can take a look.
You just need to make sure the CamelTransportFactory which you get from CXF Bus is injected with right camel context.

[1]https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/JaxWSCamelConduitTest.java
[2]https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/JaxWSCamelDestinationTest.java
[3]https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/JaxWSCamelTestSupport.java


--  
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, January 6, 2013 at 9:10 AM, Willem jiang wrote:

> Hi Lars,
>  
> Current you have to use Spring to configure the camel transport for the CXF client, if you want to do it with pure Java you have to manage the CXF Bus yourself.
> I will try to write an example to show you how to do it with pure Java, when I get some time later today.
>  
>  
> --  
> 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 Saturday, January 5, 2013 at 11:50 PM, helander wrote:
>  
> > Thanks,
> >  
> > do you know where I can find an example how to do this that are in pure Java
> > (no Spring) ?
> >  
> > Thanks Lars
> >  
> >  
> >  
> > --
> > View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5724967.html
> > Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
>  




Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by Willem jiang <wi...@gmail.com>.
Hi Lars,

Current you have to use Spring to configure the camel transport for the CXF client, if you want to do it with pure Java you have to manage the CXF Bus yourself.
I will try to write an example to show you how to do it with pure Java, when I get some time later today.


--  
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 Saturday, January 5, 2013 at 11:50 PM, helander wrote:

> Thanks,
>  
> do you know where I can find an example how to do this that are in pure Java
> (no Spring) ?
>  
> Thanks Lars
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5724967.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by helander <le...@gmail.com>.
Thanks,

do you know where I can find an example how to do this that are in pure Java
(no Spring) ?

Thanks Lars



--
View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5724967.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by Willem jiang <wi...@gmail.com>.
It looks like you just need to route the soap message to different service location dynamically.
I think you can try out the camel transport for CXF[1]

[1]http://camel.apache.org/camel-transport-for-cxf.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 Saturday, January 5, 2013 at 11:25 PM, helander wrote:

> The general pattern is:
>  
> Application -> Java service interface -> SOAP client -> Routing {  
> dynamically determine address and transport method, attach transport
> specific headers } -> Send to (dynamically selected service location)
>  
> ... and I would like to do this using Java (i.e. no Spring)
>  
> Thanks Lars
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5724963.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by helander <le...@gmail.com>.
The general pattern is:

Application -> Java service interface -> SOAP client -> Routing { 
dynamically determine address and transport method, attach transport
specific headers  } -> Send to (dynamically selected service location)

... and I would like to do this using Java (i.e. no Spring)

Thanks Lars



--
View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949p5724963.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Producing/consuming SOAP messages to/from POJOs using camel-cxf

Posted by Willem jiang <wi...@gmail.com>.
I'm not sure what kind of processing you are doing, but if you can setup right message header (operation name) and message body, you should have no trouble to invoke the service.
Maybe you can show us, you want prepare the SOAP message for invocation.


--  
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 Saturday, January 5, 2013 at 6:51 PM, helander wrote:

> I am using camel-cxf for calling a web service. I am using a producer
> template to create an exchange that has an in message that "contains" the
> web service call details (input parameters as POJOs, operation name, ). The
> exchange is sent to a route that looks as:
>  
> from("direct:xyz").to("cxf:http://......");
>  
> This works very well and the service is properly called, but what if I
> wanted to do some processing in the route of the generated SOAP messages and
> not having the service called, how would I do then?  
>  
> Thanks
>  
> Lars
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Producing-consuming-SOAP-messages-to-from-POJOs-using-camel-cxf-tp5724949.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).