2
votes

I am extending AbstractPhaseInterceptor, and I want to get hold of the JAXWS web service object, in INVOKE or PRE_INVOKE phase. How do I do this?

To be clear, I need to get a reference to the object that implements the web service methods, so:

@WebService(...)
public class ExampleWebService
{
   @WebMethod(...)
   public void doSomething(...)
   {
   }
}

public class MyInterceptor
    extends AbstractPhaseInterceptor<Message>
{
    public MyInterceptor()
    {
        super(Phase.INVOKE);
    }

    @Override
    public void handleMessage(Message message)
            throws Fault
    {
        ExampleWebService serviceObject = getServiceObject(message);
    }

    private static ExampleWebService getServiceObject(Message messsage)
    {
        // how do I implement this?
    }
}
1

1 Answers

1
votes

I do not test the code but something like that probably works.

import org.apache.cxf.endpoint.Server;
import org.apache.cxf.frontend.ServerFactoryBean;
...

Server server = serverFactoryBean.create();
MyInterceptor myInterceptor = new MyInterceptor(server.getEndpoint());
server.getEndpoint().getInInterceptor().add(myInterceptor);