You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Przemyslaw Bielicki <pb...@gmail.com> on 2014/09/12 14:40:22 UTC

Programatic CXF features on JAX-WS endpoin

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?

Many thanks,
Przemyslaw BIELICKI

Re: Programatic CXF features on JAX-WS endpoin

Posted by Daniel Kulp <dk...@apache.org>.
On Sep 12, 2014, at 8:40 AM, Przemyslaw Bielicki <pb...@gmail.com> 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
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com