You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Coder One <co...@yahoo.com> on 2009/11/20 00:40:20 UTC

CXF SOAP over JMS and Camel/Generic Interceptor

interface WebService
{
    String greeting();
}

class WebServiceImpl
{
   public String greeting()
  {
      return("Hello, world");
   }

}

Using Spring, CXF simple front-end, the client code just needs a reference the interface WebService and CXF will simply generate the stub/binding to allow the client to invoke the server side implementation.

However, I need to pipe in the Camel code in between at both end-points and intercept the call.  Is that possible at all?

[CXF-WebService Client] [Camel] [JMS] [Camel] [CXF-WebService Server]

Rather than Camel, can I intercept the calls and do the following on both the client and the server sides:

1. Let the SOAP goes through.
2. Modify the SOAP and pass it on.

Any restrictions?  I would greatly appreciate all points to docs, examples, etc...

Thanks


      

Re: Hooking into CXF's XML<->Object handling?

Posted by John Klassa <jo...@klassa.com>.
Chris,

Here's some sample code that may help.  It uses JAXB directly, to generate an XML representation of your object.  In this case, the "outbound message" is defined via an XML schema (.xsd) that is turned into a Java object via xjc.sh.  Basically, you populate the resulting Java object with information, and then use the attached code to marshall it into XML.  What I sent should help you figure out what's important, and what you can ignore (for now).

(I realize you asked for a way to hook into what CXF does, but thought this may help as an alternative, if you can't get the "do it like CXF does it" route to work.)

HTH,
JK


Re: Hooking into CXF's XML<->Object handling?

Posted by Benson Margulies <bi...@gmail.com>.
We have a plain HTTP binding, which I'm not an expert on.

On Fri, Nov 20, 2009 at 1:19 PM, Kessel, Christopher <ckessel@transunion.com
> wrote:

> I've got a JAXWS web service setup, much like the CXF tutorials. It's
> wonderful. I have some annotated classes (XmlElement, XmlAttributes,
> etc). I create the Java object on the client, call the client proxy, and
> poof on the server I have the resulting Java object to use in the
> invoked web service method. Life is good :).
>
> However, I need to support a straight xml over http interface as well as
> SOAP. The object XML is the same inside the soap message as the object
> XML I'll be receiving in my straight xml over http support. I'd like to
> hook into whatever code CXF is using to do the Java<->XML translation.
> I've been looking at the JAXB stuff and it's way more complicated. It
> wants me to create an ObjectFactory, create marshal() and unmarshal()
> methods, etc.
>
> It seems like there must be a simpler way. CXF is doing this all for me
> beautifully right now within the web service call so some subportion of
> that is already doing the XML-to-object translation work. Is there a way
> I can make us of that rather than going down the pure JAXB route which,
> frankly, looks painful.
>
> Thanks,
> Chris
>
>

Re: Hooking into CXF's XML<->Object handling?

Posted by Daniel Kulp <dk...@apache.org>.
You want the XML binding in CXF.  See:
http://cxf.apache.org/docs/pure-xml.html

It sounds like you are doing java first.  For the jaxws:endpoint config, add 
the bindingUri attribute set to 
http://cxf.apache.org/bindings/xformat

I THINK that should do it.  

Dan


On Fri November 20 2009 1:19:02 pm Kessel, Christopher wrote:
> I've got a JAXWS web service setup, much like the CXF tutorials. It's
> wonderful. I have some annotated classes (XmlElement, XmlAttributes,
> etc). I create the Java object on the client, call the client proxy, and
> poof on the server I have the resulting Java object to use in the
> invoked web service method. Life is good :).
> 
> However, I need to support a straight xml over http interface as well as
> SOAP. The object XML is the same inside the soap message as the object
> XML I'll be receiving in my straight xml over http support. I'd like to
> hook into whatever code CXF is using to do the Java<->XML translation.
> I've been looking at the JAXB stuff and it's way more complicated. It
> wants me to create an ObjectFactory, create marshal() and unmarshal()
> methods, etc.
> 
> It seems like there must be a simpler way. CXF is doing this all for me
> beautifully right now within the web service call so some subportion of
> that is already doing the XML-to-object translation work. Is there a way
> I can make us of that rather than going down the pure JAXB route which,
> frankly, looks painful.
> 
> Thanks,
> Chris
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Hooking into CXF's XML<->Object handling?

Posted by "Kessel, Christopher" <ck...@transunion.com>.
I've got a JAXWS web service setup, much like the CXF tutorials. It's
wonderful. I have some annotated classes (XmlElement, XmlAttributes,
etc). I create the Java object on the client, call the client proxy, and
poof on the server I have the resulting Java object to use in the
invoked web service method. Life is good :).

However, I need to support a straight xml over http interface as well as
SOAP. The object XML is the same inside the soap message as the object
XML I'll be receiving in my straight xml over http support. I'd like to
hook into whatever code CXF is using to do the Java<->XML translation.
I've been looking at the JAXB stuff and it's way more complicated. It
wants me to create an ObjectFactory, create marshal() and unmarshal()
methods, etc. 

It seems like there must be a simpler way. CXF is doing this all for me
beautifully right now within the web service call so some subportion of
that is already doing the XML-to-object translation work. Is there a way
I can make us of that rather than going down the pure JAXB route which,
frankly, looks painful.

Thanks,
Chris
 

Re: CXF SOAP over JMS and Camel/Generic Interceptor

Posted by Coder One <co...@yahoo.com>.
This is cool.  I have to try it out.  

Thanks,


--- On Fri, 11/20/09, Christian Schneider <ch...@die-schneider.net> wrote:

> From: Christian Schneider <ch...@die-schneider.net>
> Subject: Re: CXF SOAP over JMS and Camel/Generic Interceptor
> To: users@cxf.apache.org
> Date: Friday, November 20, 2009, 1:21 AM
> You can specify a binding file for
> code generation like in the wsdl first example. There you
> can enable the async mapping.
> This will generate client code where you have a listener
> for the response.
> 
> Will this help?
> 
> <jaxws:bindings wsdlLocation="CustomerService.wsdl"
>          xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>          xmlns:xs="http://www.w3.org/2001/XMLSchema"
>          xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> 
> <jaxws:enableAsyncMapping>true</jaxws:enableAsyncMapping>
> </jaxws:bindings>
> 
> Greetings
> 
> Christian
> 
> Coder One schrieb:
> > Hi,
> > 
> > A webservice call is usually synchronous, so in the
> case of integrating with Camel and using JMS, I actually
> need an async model.
> > 
> > Would it be possible to configure CXF to route the
> SOAP to Camel, return something to the caller thorough the
> client stub, and let camel deliver the real SOAP response to
> the app using some listener mechanism at a later time?
> > 
> > Thanks...
> > 
> > --- On Thu, 11/19/09, Christian Schneider <ch...@die-schneider.net>
> wrote:
> > 
> >   
> >> From: Christian Schneider <ch...@die-schneider.net>
> >> Subject: Re: CXF SOAP over JMS and Camel/Generic
> Interceptor
> >> To: users@cxf.apache.org
> >> Date: Thursday, November 19, 2009, 4:01 PM
> >> There is an example for SOAP / JMS
> >> with CXF and Camel on:
> >> http://camel.apache.org/better-jms-transport-for-cxf-webservice-using-apache-camel.html
> >> 
> >> If you only want to mess with the SOAP then you
> can use a
> >> CXF interceptor and do not need o use camel. See:
> >> http://cwiki.apache.org/CXF20DOC/interceptors.html
> >> 
> >> Greetings
> >> 
> >> Christian
> >> 
> >> Coder One schrieb:
> >>     
> >>> interface WebService
> >>> {
> >>>      String greeting();
> >>> }
> >>> 
> >>> class WebServiceImpl
> >>> {
> >>>     public String
> greeting()
> >>>    {
> >>>        return("Hello,
> >>>       
> >> world");
> >>     
> >>>     }
> >>> 
> >>> }
> >>> 
> >>> Using Spring, CXF simple front-end, the client
> code
> >>>       
> >> just needs a reference the interface WebService
> and CXF will
> >> simply generate the stub/binding to allow the
> client to
> >> invoke the server side implementation.
> >>     
> >>> However, I need to pipe in the Camel code in
> between
> >>>       
> >> at both end-points and intercept the call. 
> Is that
> >> possible at all?
> >>     
> >>> [CXF-WebService Client] [Camel] [JMS] [Camel]
> >>>       
> >> [CXF-WebService Server]
> >>     
> >>> Rather than Camel, can I intercept the calls
> and do
> >>>       
> >> the following on both the client and the server
> sides:
> >>     
> >>> 1. Let the SOAP goes through.
> >>> 2. Modify the SOAP and pass it on.
> >>> 
> >>> Any restrictions?  I would greatly
> appreciate all
> >>>       
> >> points to docs, examples, etc...
> >>     
> >>> Thanks
> >>> 
> >>> 
> >>>        
> >>>          
> >> -- 
> >> Christian Schneider
> >> ---
> >> http://www.liquid-reality.de
> >> 
> >> 
> >>     
> > 
> > 
> >       
> >   
> 
> 


      

Re: CXF SOAP over JMS and Camel/Generic Interceptor

Posted by Christian Schneider <ch...@die-schneider.net>.
You can specify a binding file for code generation like in the wsdl 
first example. There you can enable the async mapping.
This will generate client code where you have a listener for the response.

Will this help?

<jaxws:bindings wsdlLocation="CustomerService.wsdl"
          xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <jaxws:enableAsyncMapping>true</jaxws:enableAsyncMapping>
</jaxws:bindings>

Greetings

Christian

Coder One schrieb:
> Hi,
>
> A webservice call is usually synchronous, so in the case of integrating with Camel and using JMS, I actually need an async model.
>
> Would it be possible to configure CXF to route the SOAP to Camel, return something to the caller thorough the client stub, and let camel deliver the real SOAP response to the app using some listener mechanism at a later time?
>
> Thanks...
>
> --- On Thu, 11/19/09, Christian Schneider <ch...@die-schneider.net> wrote:
>
>   
>> From: Christian Schneider <ch...@die-schneider.net>
>> Subject: Re: CXF SOAP over JMS and Camel/Generic Interceptor
>> To: users@cxf.apache.org
>> Date: Thursday, November 19, 2009, 4:01 PM
>> There is an example for SOAP / JMS
>> with CXF and Camel on:
>> http://camel.apache.org/better-jms-transport-for-cxf-webservice-using-apache-camel.html
>>
>> If you only want to mess with the SOAP then you can use a
>> CXF 
>> interceptor and do not need o use camel. See:
>> http://cwiki.apache.org/CXF20DOC/interceptors.html
>>
>> Greetings
>>
>> Christian
>>
>> Coder One schrieb:
>>     
>>> interface WebService
>>> {
>>>      String greeting();
>>> }
>>>
>>> class WebServiceImpl
>>> {
>>>     public String greeting()
>>>    {
>>>        return("Hello,
>>>       
>> world");
>>     
>>>     }
>>>
>>> }
>>>
>>> Using Spring, CXF simple front-end, the client code
>>>       
>> just needs a reference the interface WebService and CXF will
>> simply generate the stub/binding to allow the client to
>> invoke the server side implementation.
>>     
>>> However, I need to pipe in the Camel code in between
>>>       
>> at both end-points and intercept the call.  Is that
>> possible at all?
>>     
>>> [CXF-WebService Client] [Camel] [JMS] [Camel]
>>>       
>> [CXF-WebService Server]
>>     
>>> Rather than Camel, can I intercept the calls and do
>>>       
>> the following on both the client and the server sides:
>>     
>>> 1. Let the SOAP goes through.
>>> 2. Modify the SOAP and pass it on.
>>>
>>> Any restrictions?  I would greatly appreciate all
>>>       
>> points to docs, examples, etc...
>>     
>>> Thanks
>>>
>>>
>>>        
>>>
>>>    
>>>       
>> -- 
>>
>> Christian Schneider
>> ---
>> http://www.liquid-reality.de
>>
>>
>>     
>
>
>       
>
>   


Re: CXF SOAP over JMS and Camel/Generic Interceptor

Posted by Coder One <co...@yahoo.com>.
Hi,

A webservice call is usually synchronous, so in the case of integrating with Camel and using JMS, I actually need an async model.

Would it be possible to configure CXF to route the SOAP to Camel, return something to the caller thorough the client stub, and let camel deliver the real SOAP response to the app using some listener mechanism at a later time?

Thanks...

--- On Thu, 11/19/09, Christian Schneider <ch...@die-schneider.net> wrote:

> From: Christian Schneider <ch...@die-schneider.net>
> Subject: Re: CXF SOAP over JMS and Camel/Generic Interceptor
> To: users@cxf.apache.org
> Date: Thursday, November 19, 2009, 4:01 PM
> There is an example for SOAP / JMS
> with CXF and Camel on:
> http://camel.apache.org/better-jms-transport-for-cxf-webservice-using-apache-camel.html
> 
> If you only want to mess with the SOAP then you can use a
> CXF 
> interceptor and do not need o use camel. See:
> http://cwiki.apache.org/CXF20DOC/interceptors.html
> 
> Greetings
> 
> Christian
> 
> Coder One schrieb:
> > interface WebService
> > {
> >     String greeting();
> > }
> >
> > class WebServiceImpl
> > {
> >    public String greeting()
> >   {
> >       return("Hello,
> world");
> >    }
> >
> > }
> >
> > Using Spring, CXF simple front-end, the client code
> just needs a reference the interface WebService and CXF will
> simply generate the stub/binding to allow the client to
> invoke the server side implementation.
> >
> > However, I need to pipe in the Camel code in between
> at both end-points and intercept the call.  Is that
> possible at all?
> >
> > [CXF-WebService Client] [Camel] [JMS] [Camel]
> [CXF-WebService Server]
> >
> > Rather than Camel, can I intercept the calls and do
> the following on both the client and the server sides:
> >
> > 1. Let the SOAP goes through.
> > 2. Modify the SOAP and pass it on.
> >
> > Any restrictions?  I would greatly appreciate all
> points to docs, examples, etc...
> >
> > Thanks
> >
> >
> >       
> >
> >   
> 
> 
> -- 
> 
> Christian Schneider
> ---
> http://www.liquid-reality.de
> 
> 


      

Re: CXF SOAP over JMS and Camel/Generic Interceptor

Posted by Christian Schneider <ch...@die-schneider.net>.
There is an example for SOAP / JMS with CXF and Camel on:
http://camel.apache.org/better-jms-transport-for-cxf-webservice-using-apache-camel.html

If you only want to mess with the SOAP then you can use a CXF 
interceptor and do not need o use camel. See:
http://cwiki.apache.org/CXF20DOC/interceptors.html

Greetings

Christian

Coder One schrieb:
> interface WebService
> {
>     String greeting();
> }
>
> class WebServiceImpl
> {
>    public String greeting()
>   {
>       return("Hello, world");
>    }
>
> }
>
> Using Spring, CXF simple front-end, the client code just needs a reference the interface WebService and CXF will simply generate the stub/binding to allow the client to invoke the server side implementation.
>
> However, I need to pipe in the Camel code in between at both end-points and intercept the call.  Is that possible at all?
>
> [CXF-WebService Client] [Camel] [JMS] [Camel] [CXF-WebService Server]
>
> Rather than Camel, can I intercept the calls and do the following on both the client and the server sides:
>
> 1. Let the SOAP goes through.
> 2. Modify the SOAP and pass it on.
>
> Any restrictions?  I would greatly appreciate all points to docs, examples, etc...
>
> Thanks
>
>
>       
>
>   


-- 

Christian Schneider
---
http://www.liquid-reality.de