On Sep 12, 2014, at 8:40 AM, Przemyslaw Bielicki <[email protected]> wrote:

> Hi,
> 
> how can I add/inject custom CXF features/interceptors to the client
> endpoint created using JAX-WS API:
> 
>    QName serviceName = new QName("...", "...");
>    Service service = Service.create(serviceName);
>    service.addPort(serviceName, SOAPBinding.SOAP12HTTP_BINDING, "...");
>    Dispatch<Object> disp = service.createDispatch(serviceName,
> jaxbContext, Service.Mode.PAYLOAD);
>    ...
>    disp.invoke(req);
> 
> After debugging I can see that org.apache.cxf.jaxws.ServiceImpl creates
> org.apache.cxf.jaxws.support.JaxWsEndpointImpl object but I see no way of
> customizing it. What I need is to add some CXF features/interceptors to the
> endpoint after it has been created.
> 
> Any "standard" CXF way of doing it?

There are a bunch of ways, but the two most common ways of doing this:

1) Starting with CXF 3.0, almost all (maybe all) of the CXF Features subclass 
WebServiceFeature.  Thus, when you create the Dispatch object, you can pass 
them in to the createDispatch call.    That’s certainly the easiest.

2)  You can cast the Dispatch object to the org.apache.cxf.jaxws.DispatchImpl 
and call the getClient() method on it to get the client.  From there, you can 
add interceptors, etc…


-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to