I'm attempting to use WS-security with my Apache CXF client. I need to get a hold of the client endpoint so I can add a WSS4J interceptor. However, when I call ClientProxy.getClient()
I get an IllegalArgumentException
with the following message:
not a proxy instance
Code:
MailingService_ServiceLocator serviceLocator = new MailingService_ServiceLocator();
MailingService_PortType port = serviceLocator.getMailingServicePort();
Client client = ClientProxy.getClient(port); // throws exception
...
// Create client interceptor
AuthenticationInterceptor authenticationInterceptor =
new AuthenticationInterceptor(schemaNS, outprops, organizationName, null);
client.getEndpoint().getOutInterceptors().add(authenticationInterceptor);
Trace:
java.lang.IllegalArgumentException: not a proxy instance
at java.lang.reflect.Proxy.getInvocationHandler(Unknown Source)
at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:93)