You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Marco Pas <ma...@gmail.com> on 2012/08/22 12:32:41 UTC
How to add interceptors to a wsdl2java generated client?
Hi there i am trying to add some logging to the inbound / outbound
traffic of a wsdl2java generated client.
I have the client generated and using it as follows:
pseudo code:
MyService ws = new MyService().getMyServiceSoap12();
((BindingProvider)ws).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
webServiceAddress); // for dynamic endpoints...
Is there any way i can add some interceptors? I am using it in a
Spring application by the way!
Thanks in advance.
Greetings Marco
Re: How to add interceptors to a wsdl2java generated client?
Posted by Freeman Fang <fr...@gmail.com>.
Hi,
You can use code to do it, something like
Client client = ClientProxy.getClient(ws);
client.getInInterceptors().add(your_in_interceptor);
client.getOutInterceptors().add(your_out_interceptor);
Freeman
-------------
Freeman Fang
FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042
On 2012-8-22, at 下午6:32, Marco Pas wrote:
> Hi there i am trying to add some logging to the inbound / outbound
> traffic of a wsdl2java generated client.
> I have the client generated and using it as follows:
>
> pseudo code:
>
> MyService ws = new MyService().getMyServiceSoap12();
> ((BindingProvider)ws).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
> webServiceAddress); // for dynamic endpoints...
>
> Is there any way i can add some interceptors? I am using it in a
> Spring application by the way!
>
> Thanks in advance.
>
> Greetings Marco
Re: How to add interceptors to a wsdl2java generated client?
Posted by Michael Täschner <m....@gmail.com>.
Hi Marco,
sure, using the BindingProvider you are on the right track:
import org.apache.cxf.headers.Header;
import org.apache.cxf.jaxb.JAXBDataBinding;
...
final Header header = new Header(headerQName, headerObject new
JAXBDataBinding(headerObject.class));
final List<Header> headers = new ArrayList<Header>();
headers.add(header);
((BindingProvider)ws).getRequestContext().put(Header.HEADER_LIST, headers);
Regards,
Michael
2012/8/22 Marco Pas <ma...@gmail.com>
> Hi there i am trying to add some logging to the inbound / outbound
> traffic of a wsdl2java generated client.
> I have the client generated and using it as follows:
>
> pseudo code:
>
> MyService ws = new MyService().getMyServiceSoap12();
>
> ((BindingProvider)ws).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
> webServiceAddress); // for dynamic endpoints...
>
> Is there any way i can add some interceptors? I am using it in a
> Spring application by the way!
>
> Thanks in advance.
>
> Greetings Marco
>