You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Ted <r6...@gmail.com> on 2012/04/26 05:20:22 UTC

how do I exclude rest services from soap interceptors

Does anyone know if it's possible to exclude rest services from soap
interceptors?

My basic problems is ... I have both SOAP and Rest services exposed. I use
WSS4J interceptor for securing my SOAP calls.

The problem is when I make a rest call, it sends it through the soap
interceptor and I end up with an exception because it's trying to cast to a
Soap message. (java.lang.ClassCastException:
org.apache.cxf.message.XMLMessage cannot be cast to
org.apache.cxf.binding.soap.SoapMessage)

My preferred solution would be to just use 1 bus and have a way to either
apply the WSS4J interceptor to the soap calls only, or to some how exclude
the jaxrs:server from the WSS4J interceptor. I would prefer to not have to
try and setup 2 buses... it looks like if I setup a second bus I have to
write a subclass the CXFServlet so I can set the bus? or is there a simple
way to setup 2 buses on the CXFServlet?

-- 
Ted.

Re: how do I exclude rest services from soap interceptors

Posted by Daniel Kulp <dk...@apache.org>.
On Friday, April 27, 2012 11:17:04 AM Sergey Beryozkin wrote:
> I'm interested myself how it would it work if say two cxf:bus were
> declared, with the 1st one referenced from jaxrs:server and the second
> one - from jaxws:endpoint, but I'm not sure how CXFServlet will manage
> it :-)

It MAY actually work if you add:

<bean id="org.apache.cxf.transport.http.DestinationRegistry" 
class="org.apache.cxf.transport.http.DestinationRegistryImpl"/>

To the spring config.    The   HTTPTransportFactory that each of the two 
Bus's create would then share the common registry.   Thus a single Servlet 
can likely be used.   Not 100% sure, but it may be worth a shot.




-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: how do I exclude rest services from soap interceptors

Posted by Ted <r6...@gmail.com>.
I couldn't get CXFServet to do it properly, as far as I can tell from the
source, the only real way would be to subclass CXFServlet then make the
setBus call with the second bus.

I've opted to go the route of just declaring each interceptor manually
right now and maybe I'll fiddle more later once I'm more sure of what I'm
doing.


On Fri, Apr 27, 2012 at 8:17 PM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi
>
> On 27/04/12 10:03, Ted wrote:
>
>> yupp, I've got a workable solution right now by enumerating the
>> interceptor
>> on each end point right now, but that's a lot of cut and paste / duplicate
>> declarations so it's not ideal.
>>
>> I was hoping to just have a broad interceptor declaration for the entire
>> jaxws bus but not on the jaxrw bus, but it doesn't look like it's
>> possible,
>> at least not with out a lot of great difficulty in declaring 2 buses.
>>
>> I use to just declare the interceptor in cxf:bus... so it was always
>> simple
>> and complete.
>>
>>
> Having to refer to JAX-WS specific interceptors from jaxws:endpoint and
> JAX-RS specific interceptors from jaxrs:server elements, while still being
> able to declare the share-able interceptors in cxf:bus seems like a
> reasonable option to me. I agree a bit more typing is needed, but you have
> less than 10 endpoints then it should be OK :-)
>
> I'm interested myself how it would it work if say two cxf:bus were
> declared, with the 1st one referenced from jaxrs:server and the second one
> - from jaxws:endpoint, but I'm not sure how CXFServlet will manage it :-)
>
> Sergey
>
>
>
>> On Fri, Apr 27, 2012 at 6:33 PM, Aki Yoshida<elakito@googlemail.com**>
>>  wrote:
>>
>>  2012/4/26 Ted<r6...@gmail.com>:
>>>
>>>> I though you could but when I looked again I couldn't find any
>>>> documentation on doing so.
>>>>
>>>> It would be a "workable" solution if I could find out how to do that.
>>>>
>>> It's
>>>
>>>> not ideal though as I have a slew of soap and rest services, it would be
>>>> error prone to manually ensure security on each end point adverse to a
>>>> complete coverage approach.
>>>>
>>>
>>> have you looked in here?
>>> http://cxf.apache.org/docs/**jax-ws-configuration.html<http://cxf.apache.org/docs/jax-ws-configuration.html>
>>>
>>>
>>>> On Thu, Apr 26, 2012 at 7:11 PM, Sergey Beryozkin<sberyozkin@gmail.com
>>>> wrote:
>>>>
>>>>  Hi,
>>>>>
>>>>> On 26/04/12 04:20, Ted wrote:
>>>>>
>>>>>  Does anyone know if it's possible to exclude rest services from soap
>>>>>> interceptors?
>>>>>>
>>>>>> My basic problems is ... I have both SOAP and Rest services exposed. I
>>>>>>
>>>>> use
>>>
>>>> WSS4J interceptor for securing my SOAP calls.
>>>>>>
>>>>>> The problem is when I make a rest call, it sends it through the soap
>>>>>> interceptor and I end up with an exception because it's trying to cast
>>>>>>
>>>>> to
>>>
>>>> a
>>>>>> Soap message. (java.lang.ClassCastException:
>>>>>> org.apache.cxf.message.****XMLMessage cannot be cast to
>>>>>> org.apache.cxf.binding.soap.****SoapMessage)
>>>>>>
>>>>>> My preferred solution would be to just use 1 bus and have a way to
>>>>>>
>>>>> either
>>>
>>>> apply the WSS4J interceptor to the soap calls only, or to some how
>>>>>>
>>>>> exclude
>>>
>>>> the jaxrs:server from the WSS4J interceptor. I would prefer to not
>>>>>>
>>>>> have to
>>>
>>>> try and setup 2 buses... it looks like if I setup a second bus I have
>>>>>>
>>>>> to
>>>
>>>> write a subclass the CXFServlet so I can set the bus? or is there a
>>>>>>
>>>>> simple
>>>
>>>> way to setup 2 buses on the CXFServlet?
>>>>>>
>>>>>>
>>>>>>  Can you configure interceptors on per-endpoint basis ? Example, have
>>>>> WSS4JInInterceptor configured within
>>>>>
>>>> jaxws:endpoint/jaxws:****inInterceptors
>>>
>>>> ?
>>>>>
>>>>> Cheers, Sergey
>>>>>
>>>>>
>>>>> --
>>>>> Sergey Beryozkin
>>>>>
>>>>> Talend Community Coders
>>>>> http://coders.talend.com/
>>>>>
>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Ted.
>>>>
>>>
>>>
>>
>>
>>
>


-- 
Ted.

Re: how do I exclude rest services from soap interceptors

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 27/04/12 10:03, Ted wrote:
> yupp, I've got a workable solution right now by enumerating the interceptor
> on each end point right now, but that's a lot of cut and paste / duplicate
> declarations so it's not ideal.
>
> I was hoping to just have a broad interceptor declaration for the entire
> jaxws bus but not on the jaxrw bus, but it doesn't look like it's possible,
> at least not with out a lot of great difficulty in declaring 2 buses.
>
> I use to just declare the interceptor in cxf:bus... so it was always simple
> and complete.
>

Having to refer to JAX-WS specific interceptors from jaxws:endpoint and 
JAX-RS specific interceptors from jaxrs:server elements, while still 
being able to declare the share-able interceptors in cxf:bus seems like 
a reasonable option to me. I agree a bit more typing is needed, but you 
have less than 10 endpoints then it should be OK :-)

I'm interested myself how it would it work if say two cxf:bus were 
declared, with the 1st one referenced from jaxrs:server and the second 
one - from jaxws:endpoint, but I'm not sure how CXFServlet will manage 
it :-)

Sergey

>
> On Fri, Apr 27, 2012 at 6:33 PM, Aki Yoshida<el...@googlemail.com>  wrote:
>
>> 2012/4/26 Ted<r6...@gmail.com>:
>>> I though you could but when I looked again I couldn't find any
>>> documentation on doing so.
>>>
>>> It would be a "workable" solution if I could find out how to do that.
>> It's
>>> not ideal though as I have a slew of soap and rest services, it would be
>>> error prone to manually ensure security on each end point adverse to a
>>> complete coverage approach.
>>
>> have you looked in here?
>> http://cxf.apache.org/docs/jax-ws-configuration.html
>>
>>>
>>> On Thu, Apr 26, 2012 at 7:11 PM, Sergey Beryozkin<sberyozkin@gmail.com
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> On 26/04/12 04:20, Ted wrote:
>>>>
>>>>> Does anyone know if it's possible to exclude rest services from soap
>>>>> interceptors?
>>>>>
>>>>> My basic problems is ... I have both SOAP and Rest services exposed. I
>> use
>>>>> WSS4J interceptor for securing my SOAP calls.
>>>>>
>>>>> The problem is when I make a rest call, it sends it through the soap
>>>>> interceptor and I end up with an exception because it's trying to cast
>> to
>>>>> a
>>>>> Soap message. (java.lang.ClassCastException:
>>>>> org.apache.cxf.message.**XMLMessage cannot be cast to
>>>>> org.apache.cxf.binding.soap.**SoapMessage)
>>>>>
>>>>> My preferred solution would be to just use 1 bus and have a way to
>> either
>>>>> apply the WSS4J interceptor to the soap calls only, or to some how
>> exclude
>>>>> the jaxrs:server from the WSS4J interceptor. I would prefer to not
>> have to
>>>>> try and setup 2 buses... it looks like if I setup a second bus I have
>> to
>>>>> write a subclass the CXFServlet so I can set the bus? or is there a
>> simple
>>>>> way to setup 2 buses on the CXFServlet?
>>>>>
>>>>>
>>>> Can you configure interceptors on per-endpoint basis ? Example, have
>>>> WSS4JInInterceptor configured within
>> jaxws:endpoint/jaxws:**inInterceptors
>>>> ?
>>>>
>>>> Cheers, Sergey
>>>>
>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>> Blog: http://sberyozkin.blogspot.com
>>>>
>>>
>>>
>>>
>>> --
>>> Ted.
>>
>
>
>


Re: how do I exclude rest services from soap interceptors

Posted by Ted <r6...@gmail.com>.
yupp, I've got a workable solution right now by enumerating the interceptor
on each end point right now, but that's a lot of cut and paste / duplicate
declarations so it's not ideal.

I was hoping to just have a broad interceptor declaration for the entire
jaxws bus but not on the jaxrw bus, but it doesn't look like it's possible,
at least not with out a lot of great difficulty in declaring 2 buses.

I use to just declare the interceptor in cxf:bus... so it was always simple
and complete.


On Fri, Apr 27, 2012 at 6:33 PM, Aki Yoshida <el...@googlemail.com> wrote:

> 2012/4/26 Ted <r6...@gmail.com>:
> > I though you could but when I looked again I couldn't find any
> > documentation on doing so.
> >
> > It would be a "workable" solution if I could find out how to do that.
> It's
> > not ideal though as I have a slew of soap and rest services, it would be
> > error prone to manually ensure security on each end point adverse to a
> > complete coverage approach.
>
> have you looked in here?
> http://cxf.apache.org/docs/jax-ws-configuration.html
>
> >
> > On Thu, Apr 26, 2012 at 7:11 PM, Sergey Beryozkin <sberyozkin@gmail.com
> >wrote:
> >
> >> Hi,
> >>
> >> On 26/04/12 04:20, Ted wrote:
> >>
> >>> Does anyone know if it's possible to exclude rest services from soap
> >>> interceptors?
> >>>
> >>> My basic problems is ... I have both SOAP and Rest services exposed. I
> use
> >>> WSS4J interceptor for securing my SOAP calls.
> >>>
> >>> The problem is when I make a rest call, it sends it through the soap
> >>> interceptor and I end up with an exception because it's trying to cast
> to
> >>> a
> >>> Soap message. (java.lang.ClassCastException:
> >>> org.apache.cxf.message.**XMLMessage cannot be cast to
> >>> org.apache.cxf.binding.soap.**SoapMessage)
> >>>
> >>> My preferred solution would be to just use 1 bus and have a way to
> either
> >>> apply the WSS4J interceptor to the soap calls only, or to some how
> exclude
> >>> the jaxrs:server from the WSS4J interceptor. I would prefer to not
> have to
> >>> try and setup 2 buses... it looks like if I setup a second bus I have
> to
> >>> write a subclass the CXFServlet so I can set the bus? or is there a
> simple
> >>> way to setup 2 buses on the CXFServlet?
> >>>
> >>>
> >> Can you configure interceptors on per-endpoint basis ? Example, have
> >> WSS4JInInterceptor configured within
> jaxws:endpoint/jaxws:**inInterceptors
> >> ?
> >>
> >> Cheers, Sergey
> >>
> >>
> >> --
> >> Sergey Beryozkin
> >>
> >> Talend Community Coders
> >> http://coders.talend.com/
> >>
> >> Blog: http://sberyozkin.blogspot.com
> >>
> >
> >
> >
> > --
> > Ted.
>



-- 
Ted.

Re: how do I exclude rest services from soap interceptors

Posted by Aki Yoshida <el...@googlemail.com>.
2012/4/26 Ted <r6...@gmail.com>:
> I though you could but when I looked again I couldn't find any
> documentation on doing so.
>
> It would be a "workable" solution if I could find out how to do that. It's
> not ideal though as I have a slew of soap and rest services, it would be
> error prone to manually ensure security on each end point adverse to a
> complete coverage approach.

have you looked in here?
http://cxf.apache.org/docs/jax-ws-configuration.html

>
> On Thu, Apr 26, 2012 at 7:11 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
>
>> Hi,
>>
>> On 26/04/12 04:20, Ted wrote:
>>
>>> Does anyone know if it's possible to exclude rest services from soap
>>> interceptors?
>>>
>>> My basic problems is ... I have both SOAP and Rest services exposed. I use
>>> WSS4J interceptor for securing my SOAP calls.
>>>
>>> The problem is when I make a rest call, it sends it through the soap
>>> interceptor and I end up with an exception because it's trying to cast to
>>> a
>>> Soap message. (java.lang.ClassCastException:
>>> org.apache.cxf.message.**XMLMessage cannot be cast to
>>> org.apache.cxf.binding.soap.**SoapMessage)
>>>
>>> My preferred solution would be to just use 1 bus and have a way to either
>>> apply the WSS4J interceptor to the soap calls only, or to some how exclude
>>> the jaxrs:server from the WSS4J interceptor. I would prefer to not have to
>>> try and setup 2 buses... it looks like if I setup a second bus I have to
>>> write a subclass the CXFServlet so I can set the bus? or is there a simple
>>> way to setup 2 buses on the CXFServlet?
>>>
>>>
>> Can you configure interceptors on per-endpoint basis ? Example, have
>> WSS4JInInterceptor configured within jaxws:endpoint/jaxws:**inInterceptors
>> ?
>>
>> Cheers, Sergey
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>
>
>
> --
> Ted.

Re: how do I exclude rest services from soap interceptors

Posted by Ted <r6...@gmail.com>.
I though you could but when I looked again I couldn't find any
documentation on doing so.

It would be a "workable" solution if I could find out how to do that. It's
not ideal though as I have a slew of soap and rest services, it would be
error prone to manually ensure security on each end point adverse to a
complete coverage approach.

On Thu, Apr 26, 2012 at 7:11 PM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi,
>
> On 26/04/12 04:20, Ted wrote:
>
>> Does anyone know if it's possible to exclude rest services from soap
>> interceptors?
>>
>> My basic problems is ... I have both SOAP and Rest services exposed. I use
>> WSS4J interceptor for securing my SOAP calls.
>>
>> The problem is when I make a rest call, it sends it through the soap
>> interceptor and I end up with an exception because it's trying to cast to
>> a
>> Soap message. (java.lang.ClassCastException:
>> org.apache.cxf.message.**XMLMessage cannot be cast to
>> org.apache.cxf.binding.soap.**SoapMessage)
>>
>> My preferred solution would be to just use 1 bus and have a way to either
>> apply the WSS4J interceptor to the soap calls only, or to some how exclude
>> the jaxrs:server from the WSS4J interceptor. I would prefer to not have to
>> try and setup 2 buses... it looks like if I setup a second bus I have to
>> write a subclass the CXFServlet so I can set the bus? or is there a simple
>> way to setup 2 buses on the CXFServlet?
>>
>>
> Can you configure interceptors on per-endpoint basis ? Example, have
> WSS4JInInterceptor configured within jaxws:endpoint/jaxws:**inInterceptors
> ?
>
> Cheers, Sergey
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>



-- 
Ted.

Re: how do I exclude rest services from soap interceptors

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi,
On 26/04/12 04:20, Ted wrote:
> Does anyone know if it's possible to exclude rest services from soap
> interceptors?
>
> My basic problems is ... I have both SOAP and Rest services exposed. I use
> WSS4J interceptor for securing my SOAP calls.
>
> The problem is when I make a rest call, it sends it through the soap
> interceptor and I end up with an exception because it's trying to cast to a
> Soap message. (java.lang.ClassCastException:
> org.apache.cxf.message.XMLMessage cannot be cast to
> org.apache.cxf.binding.soap.SoapMessage)
>
> My preferred solution would be to just use 1 bus and have a way to either
> apply the WSS4J interceptor to the soap calls only, or to some how exclude
> the jaxrs:server from the WSS4J interceptor. I would prefer to not have to
> try and setup 2 buses... it looks like if I setup a second bus I have to
> write a subclass the CXFServlet so I can set the bus? or is there a simple
> way to setup 2 buses on the CXFServlet?
>

Can you configure interceptors on per-endpoint basis ? Example, have 
WSS4JInInterceptor configured within jaxws:endpoint/jaxws:inInterceptors ?

Cheers, Sergey


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com