You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Mark Edwards <ma...@orchard-systems.co.uk> on 2007/08/08 11:08:11 UTC

Adding interceptors to a JAX-WS client via the API

Hi 

 

I'm looking for some guidance on whether I can use the API to add
interceptors to a JAX-WS client that was generated using the wsdl2java tool.
I want to implement some ws-security functionality in the client and the
documentation appears to indicate that adding a WSS4JOutInterceptor is the
way to do this.  Unfortunately, the documentation for the API usage for the
client is a bit unclear (http://cwiki.apache.org/CXF20DOC/ws-security.html),
it shows how to setup the properties for the interceptor clearly (although
the usage of "outProps.setProperty" rather than "outProps.put" worries me
slightly as outProps appears to be a Map) but not how to get the interceptor
applied to the client.  

 

I've tried several attempts to do this but none have so far worked.  I cannot
find a way to get hold of an appropriate object instance that either
implements the Client or InterceptorProvider interfaces.  I have found an
example that adds interceptors to the Bus but that applies them to all
requests going through the bus whereas I only want to do it for a particular
web service.

 

Any guidance on this would be gratefully received, even it it's to say that
I'm trying to do doing something that I shouldn't.

 

 

Mark

 

 

Mark Edwards

Orchard Information Systems Limited, 
Newcastle Technopole, Kings Manor, 
Newcastle upon Tyne, 
NE1 6PA 
United Kingdom. 
Registered in England, Number 1900078 
Tel: +44 (0)191-203 2500  Fax: +44 (0)191-230 2515 
http://www.orchard-systems.co.uk <http://www.orchard-systems.co.uk/>  

 


This e-mail and any files transmitted are confidential and is solely for the intended recipient. Unauthorised use, dissemination, distribution, copying, reproduction, modification or publication is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail from your system. 
Opinions expressed in this e-mail are those of the individual and not necessarily those of Orchard Information Systems Ltd. 

It is the responsibility of the recipient to ensure this e-mail is free from viruses. Orchard Information Systems Ltd accept no liability for any damage caused by any virus transmitted by this e-mail. 

Incoming and outgoing e-mail messages are routinely monitored for compliance with Orchard Information Systems Ltd's Internet Usage Policy.

Orchard Information Systems Ltd. Registered in England No. 1900078
Newcastle Technopole, Kings Manor, Newcastle upon Tyne, NE1 6PA

Please consider the environment before printing this e-mail. 



Re: Adding interceptors to a JAX-WS client via the API

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 08 August 2007 20:23, Glen Mazza wrote:
> This blog entry by Arsenalist may also be of help for you:
> http://arsenalist.com/2007/07/31/cxf-ws-security-using-jsr-181-interce
>ptor-annotations-xfire-migration/

That blog describes how to use the interceptors via annotations on the 
Server side.   (BTW:  thats a very nicely done example.  Thanks for that 
link.)   Unfortunately, even with 2.0.1, that doesn't work on the client 
side.   It DOES work on trunk now.

Dan


> Glen
>
> Am Mittwoch, den 08.08.2007, 10:55 +0100 schrieb Mark Edwards:
> > Hi Andrea
> >
> > Thanks for this, works a treat.
> >
> > Regards
> >
> > Mark
> >
> > -----Original Message-----
> > From: Andrea Smyth [mailto:andrea.smyth@iona.com]
> > Sent: 08 August 2007 10:29
> > To: cxf-user@incubator.apache.org
> > Subject: Re: Adding interceptors to a JAX-WS client via the API
> >
> > Hi Mark,
> >
> > You can obtain a reference to the underlying CXF client object using
> > the ClientProxy helper, for example:
> >
> > GreeterService gs = new GreeterService();
> > Greeter greeter = gs.getGreeterPort();
> >
> > org.apache.cxf.endpoint.Client client =
> > org.apache.cxf.frontend.ClientProxy.getClient(greeter);
> > org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
> > cxfEndpoint.getOutInterceptors().add(...);
> >
> > Regards,
> > Andrea.
> >
> > Mark Edwards wrote:
> > >Hi
> > >
> > >
> > >
> > >I'm looking for some guidance on whether I can use the API to add
> > >interceptors to a JAX-WS client that was generated using the
> > > wsdl2java tool. I want to implement some ws-security functionality
> > > in the client and the documentation appears to indicate that
> > > adding a WSS4JOutInterceptor is the way to do this. 
> > > Unfortunately, the documentation for the API usage for the client
> > > is a bit unclear
> > > (http://cwiki.apache.org/CXF20DOC/ws-security.html), it shows how
> > > to setup the properties for the interceptor clearly (although the
> > > usage of "outProps.setProperty" rather than "outProps.put" worries
> > > me slightly as outProps appears to be a Map) but not how to get
> > > the interceptor applied to the client.
> > >
> > >
> > >
> > >I've tried several attempts to do this but none have so far worked.
> > >  I
> >
> > cannot
> >
> > >find a way to get hold of an appropriate object instance that
> > > either implements the Client or InterceptorProvider interfaces.  I
> > > have found an example that adds interceptors to the Bus but that
> > > applies them to all requests going through the bus whereas I only
> > > want to do it for a particular web service.
> > >
> > >
> > >
> > >Any guidance on this would be gratefully received, even it it's to
> > > say that I'm trying to do doing something that I shouldn't.
> > >
> > >
> > >
> > >
> > >
> > >Mark
> > >
> > >
> > >
> > >
> > >
> > >Mark Edwards
> > >
> > >Orchard Information Systems Limited,
> > >Newcastle Technopole, Kings Manor,
> > >Newcastle upon Tyne,
> > >NE1 6PA
> > >United Kingdom.
> > >Registered in England, Number 1900078
> > >Tel: +44 (0)191-203 2500  Fax: +44 (0)191-230 2515
> > >http://www.orchard-systems.co.uk
> > > <http://www.orchard-systems.co.uk/>
> > >
> > >
> > >
> > >
> > >This e-mail and any files transmitted are confidential and is
> > > solely for the
> >
> > intended recipient. Unauthorised use, dissemination, distribution,
> > copying, reproduction, modification or publication is strictly
> > prohibited. If you have received this e-mail in error, please notify
> > the sender and permanently delete the e-mail from your system.
> >
> > >Opinions expressed in this e-mail are those of the individual and
> > > not
> >
> > necessarily those of Orchard Information Systems Ltd.
> >
> > >It is the responsibility of the recipient to ensure this e-mail is
> > > free from
> >
> > viruses. Orchard Information Systems Ltd accept no liability for any
> > damage caused by any virus transmitted by this e-mail.
> >
> > >Incoming and outgoing e-mail messages are routinely monitored for
> > > compliance
> >
> > with Orchard Information Systems Ltd's Internet Usage Policy.
> >
> > >Orchard Information Systems Ltd. Registered in England No. 1900078
> > >Newcastle Technopole, Kings Manor, Newcastle upon Tyne, NE1 6PA
> > >
> > >Please consider the environment before printing this e-mail.
> >
> > ----------------------------
> > IONA Technologies PLC (registered in Ireland)
> > Registered Number: 171387
> > Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
> > Ireland
> >
> > This e-mail and any files transmitted are confidential and is solely
> > for the intended recipient. Unauthorised use, dissemination,
> > distribution, copying, reproduction, modification or publication is
> > strictly prohibited. If you have received this e-mail in error,
> > please notify the sender and permanently delete the e-mail from your
> > system. Opinions expressed in this e-mail are those of the
> > individual and not necessarily those of Orchard Information Systems
> > Ltd.
> >
> > It is the responsibility of the recipient to ensure this e-mail is
> > free from viruses. Orchard Information Systems Ltd accept no
> > liability for any damage caused by any virus transmitted by this
> > e-mail.
> >
> > Incoming and outgoing e-mail messages are routinely monitored for
> > compliance with Orchard Information Systems Ltd's Internet Usage
> > Policy.
> >
> > Orchard Information Systems Ltd. Registered in England No. 1900078
> > Newcastle Technopole, Kings Manor, Newcastle upon Tyne, NE1 6PA
> >
> > Please consider the environment before printing this e-mail.

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

RE: Adding interceptors to a JAX-WS client via the API

Posted by Glen Mazza <gl...@verizon.net>.
This blog entry by Arsenalist may also be of help for you:
http://arsenalist.com/2007/07/31/cxf-ws-security-using-jsr-181-interceptor-annotations-xfire-migration/

Glen

Am Mittwoch, den 08.08.2007, 10:55 +0100 schrieb Mark Edwards:
> Hi Andrea
> 
> Thanks for this, works a treat.
> 
> Regards
> 
> Mark
> 
> -----Original Message-----
> From: Andrea Smyth [mailto:andrea.smyth@iona.com] 
> Sent: 08 August 2007 10:29
> To: cxf-user@incubator.apache.org
> Subject: Re: Adding interceptors to a JAX-WS client via the API
> 
> Hi Mark,
> 
> You can obtain a reference to the underlying CXF client object using the 
> ClientProxy helper, for example:
> 
> GreeterService gs = new GreeterService();
> Greeter greeter = gs.getGreeterPort();
> 
> org.apache.cxf.endpoint.Client client = 
> org.apache.cxf.frontend.ClientProxy.getClient(greeter); 
> org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
> cxfEndpoint.getOutInterceptors().add(...);
> 
> Regards,
> Andrea.
> 
> 
> 
> Mark Edwards wrote:
> 
> >Hi 
> >
> > 
> >
> >I'm looking for some guidance on whether I can use the API to add
> >interceptors to a JAX-WS client that was generated using the wsdl2java tool.
> >I want to implement some ws-security functionality in the client and the
> >documentation appears to indicate that adding a WSS4JOutInterceptor is the
> >way to do this.  Unfortunately, the documentation for the API usage for the
> >client is a bit unclear (http://cwiki.apache.org/CXF20DOC/ws-security.html),
> >it shows how to setup the properties for the interceptor clearly (although
> >the usage of "outProps.setProperty" rather than "outProps.put" worries me
> >slightly as outProps appears to be a Map) but not how to get the interceptor
> >applied to the client.  
> >
> > 
> >
> >I've tried several attempts to do this but none have so far worked.  I
> cannot
> >find a way to get hold of an appropriate object instance that either
> >implements the Client or InterceptorProvider interfaces.  I have found an
> >example that adds interceptors to the Bus but that applies them to all
> >requests going through the bus whereas I only want to do it for a particular
> >web service.
> >
> > 
> >
> >Any guidance on this would be gratefully received, even it it's to say that
> >I'm trying to do doing something that I shouldn't.
> >
> > 
> >
> > 
> >
> >Mark
> >
> > 
> >
> > 
> >
> >Mark Edwards
> >
> >Orchard Information Systems Limited, 
> >Newcastle Technopole, Kings Manor, 
> >Newcastle upon Tyne, 
> >NE1 6PA 
> >United Kingdom. 
> >Registered in England, Number 1900078 
> >Tel: +44 (0)191-203 2500  Fax: +44 (0)191-230 2515 
> >http://www.orchard-systems.co.uk <http://www.orchard-systems.co.uk/>  
> >
> > 
> >
> >
> >This e-mail and any files transmitted are confidential and is solely for the
> intended recipient. Unauthorised use, dissemination, distribution, copying,
> reproduction, modification or publication is strictly prohibited. If you have
> received this e-mail in error, please notify the sender and permanently
> delete the e-mail from your system. 
> >Opinions expressed in this e-mail are those of the individual and not
> necessarily those of Orchard Information Systems Ltd. 
> >
> >It is the responsibility of the recipient to ensure this e-mail is free from
> viruses. Orchard Information Systems Ltd accept no liability for any damage
> caused by any virus transmitted by this e-mail. 
> >
> >Incoming and outgoing e-mail messages are routinely monitored for compliance
> with Orchard Information Systems Ltd's Internet Usage Policy.
> >
> >Orchard Information Systems Ltd. Registered in England No. 1900078
> >Newcastle Technopole, Kings Manor, Newcastle upon Tyne, NE1 6PA
> >
> >Please consider the environment before printing this e-mail. 
> >
> >
> >
> >  
> >
> 
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> 
> This e-mail and any files transmitted are confidential and is solely for the intended recipient. Unauthorised use, dissemination, distribution, copying, reproduction, modification or publication is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail from your system. 
> Opinions expressed in this e-mail are those of the individual and not necessarily those of Orchard Information Systems Ltd. 
> 
> It is the responsibility of the recipient to ensure this e-mail is free from viruses. Orchard Information Systems Ltd accept no liability for any damage caused by any virus transmitted by this e-mail. 
> 
> Incoming and outgoing e-mail messages are routinely monitored for compliance with Orchard Information Systems Ltd's Internet Usage Policy.
> 
> Orchard Information Systems Ltd. Registered in England No. 1900078
> Newcastle Technopole, Kings Manor, Newcastle upon Tyne, NE1 6PA
> 
> Please consider the environment before printing this e-mail. 
> 
> 


RE: Adding interceptors to a JAX-WS client via the API

Posted by Mark Edwards <ma...@orchard-systems.co.uk>.
Hi Andrea

Thanks for this, works a treat.

Regards

Mark

-----Original Message-----
From: Andrea Smyth [mailto:andrea.smyth@iona.com] 
Sent: 08 August 2007 10:29
To: cxf-user@incubator.apache.org
Subject: Re: Adding interceptors to a JAX-WS client via the API

Hi Mark,

You can obtain a reference to the underlying CXF client object using the 
ClientProxy helper, for example:

GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterPort();

org.apache.cxf.endpoint.Client client = 
org.apache.cxf.frontend.ClientProxy.getClient(greeter); 
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
cxfEndpoint.getOutInterceptors().add(...);

Regards,
Andrea.



Mark Edwards wrote:

>Hi 
>
> 
>
>I'm looking for some guidance on whether I can use the API to add
>interceptors to a JAX-WS client that was generated using the wsdl2java tool.
>I want to implement some ws-security functionality in the client and the
>documentation appears to indicate that adding a WSS4JOutInterceptor is the
>way to do this.  Unfortunately, the documentation for the API usage for the
>client is a bit unclear (http://cwiki.apache.org/CXF20DOC/ws-security.html),
>it shows how to setup the properties for the interceptor clearly (although
>the usage of "outProps.setProperty" rather than "outProps.put" worries me
>slightly as outProps appears to be a Map) but not how to get the interceptor
>applied to the client.  
>
> 
>
>I've tried several attempts to do this but none have so far worked.  I
cannot
>find a way to get hold of an appropriate object instance that either
>implements the Client or InterceptorProvider interfaces.  I have found an
>example that adds interceptors to the Bus but that applies them to all
>requests going through the bus whereas I only want to do it for a particular
>web service.
>
> 
>
>Any guidance on this would be gratefully received, even it it's to say that
>I'm trying to do doing something that I shouldn't.
>
> 
>
> 
>
>Mark
>
> 
>
> 
>
>Mark Edwards
>
>Orchard Information Systems Limited, 
>Newcastle Technopole, Kings Manor, 
>Newcastle upon Tyne, 
>NE1 6PA 
>United Kingdom. 
>Registered in England, Number 1900078 
>Tel: +44 (0)191-203 2500  Fax: +44 (0)191-230 2515 
>http://www.orchard-systems.co.uk <http://www.orchard-systems.co.uk/>  
>
> 
>
>
>This e-mail and any files transmitted are confidential and is solely for the
intended recipient. Unauthorised use, dissemination, distribution, copying,
reproduction, modification or publication is strictly prohibited. If you have
received this e-mail in error, please notify the sender and permanently
delete the e-mail from your system. 
>Opinions expressed in this e-mail are those of the individual and not
necessarily those of Orchard Information Systems Ltd. 
>
>It is the responsibility of the recipient to ensure this e-mail is free from
viruses. Orchard Information Systems Ltd accept no liability for any damage
caused by any virus transmitted by this e-mail. 
>
>Incoming and outgoing e-mail messages are routinely monitored for compliance
with Orchard Information Systems Ltd's Internet Usage Policy.
>
>Orchard Information Systems Ltd. Registered in England No. 1900078
>Newcastle Technopole, Kings Manor, Newcastle upon Tyne, NE1 6PA
>
>Please consider the environment before printing this e-mail. 
>
>
>
>  
>

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

This e-mail and any files transmitted are confidential and is solely for the intended recipient. Unauthorised use, dissemination, distribution, copying, reproduction, modification or publication is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail from your system. 
Opinions expressed in this e-mail are those of the individual and not necessarily those of Orchard Information Systems Ltd. 

It is the responsibility of the recipient to ensure this e-mail is free from viruses. Orchard Information Systems Ltd accept no liability for any damage caused by any virus transmitted by this e-mail. 

Incoming and outgoing e-mail messages are routinely monitored for compliance with Orchard Information Systems Ltd's Internet Usage Policy.

Orchard Information Systems Ltd. Registered in England No. 1900078
Newcastle Technopole, Kings Manor, Newcastle upon Tyne, NE1 6PA

Please consider the environment before printing this e-mail. 



Re: Adding interceptors to a JAX-WS client via the API

Posted by Andrea Smyth <an...@iona.com>.
Hi Mark,

You can obtain a reference to the underlying CXF client object using the 
ClientProxy helper, for example:

GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterPort();

org.apache.cxf.endpoint.Client client = 
org.apache.cxf.frontend.ClientProxy.getClient(greeter); 
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
cxfEndpoint.getOutInterceptors().add(...);

Regards,
Andrea.



Mark Edwards wrote:

>Hi 
>
> 
>
>I'm looking for some guidance on whether I can use the API to add
>interceptors to a JAX-WS client that was generated using the wsdl2java tool.
>I want to implement some ws-security functionality in the client and the
>documentation appears to indicate that adding a WSS4JOutInterceptor is the
>way to do this.  Unfortunately, the documentation for the API usage for the
>client is a bit unclear (http://cwiki.apache.org/CXF20DOC/ws-security.html),
>it shows how to setup the properties for the interceptor clearly (although
>the usage of "outProps.setProperty" rather than "outProps.put" worries me
>slightly as outProps appears to be a Map) but not how to get the interceptor
>applied to the client.  
>
> 
>
>I've tried several attempts to do this but none have so far worked.  I cannot
>find a way to get hold of an appropriate object instance that either
>implements the Client or InterceptorProvider interfaces.  I have found an
>example that adds interceptors to the Bus but that applies them to all
>requests going through the bus whereas I only want to do it for a particular
>web service.
>
> 
>
>Any guidance on this would be gratefully received, even it it's to say that
>I'm trying to do doing something that I shouldn't.
>
> 
>
> 
>
>Mark
>
> 
>
> 
>
>Mark Edwards
>
>Orchard Information Systems Limited, 
>Newcastle Technopole, Kings Manor, 
>Newcastle upon Tyne, 
>NE1 6PA 
>United Kingdom. 
>Registered in England, Number 1900078 
>Tel: +44 (0)191-203 2500  Fax: +44 (0)191-230 2515 
>http://www.orchard-systems.co.uk <http://www.orchard-systems.co.uk/>  
>
> 
>
>
>This e-mail and any files transmitted are confidential and is solely for the intended recipient. Unauthorised use, dissemination, distribution, copying, reproduction, modification or publication is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail from your system. 
>Opinions expressed in this e-mail are those of the individual and not necessarily those of Orchard Information Systems Ltd. 
>
>It is the responsibility of the recipient to ensure this e-mail is free from viruses. Orchard Information Systems Ltd accept no liability for any damage caused by any virus transmitted by this e-mail. 
>
>Incoming and outgoing e-mail messages are routinely monitored for compliance with Orchard Information Systems Ltd's Internet Usage Policy.
>
>Orchard Information Systems Ltd. Registered in England No. 1900078
>Newcastle Technopole, Kings Manor, Newcastle upon Tyne, NE1 6PA
>
>Please consider the environment before printing this e-mail. 
>
>
>
>  
>

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland