The Dispatch things are not proxies and thus the ClientProxy.getClient call wouldn't work.
I think you need to cast the Dispatch to a CXF specific DispatchImpl and call the getClient method on it: ((org.apache.cxf.jaxws.DispatchImpl)dispatch).getClient(); Hope that helps. Dan On Feb 11, 2013, at 7:27 PM, vishp <[email protected]> wrote: > I am using jax-ws (cxf 2.4.3) dispatch client to invoke a webservice. Since > the wsdl specifies some policies, my call fails with the error > "javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can > be satisfied". > > After researching the forums, it seems I need to add an interceptor to > handle this situation. Now all the sample code that I have seen to do this > is like: > ... > Client client = ClientProxy.getClient(servicePort); > ... > > My code using the dispatch client is like: > > Service svc = Service.create(wsdlurl, serviceNs); > dispatch = svc.createDispatch(portName, SOAPMessage.class, > Service.Mode.MESSAGE); > Binding binding = dispatch.getBinding(); > List<Handler> handlerChain = binding.getHandlerChain(); > handlerChain.add(new SOAPLoggingHandler(logger)); > binding.setHandlerChain(handlerChain); > > I dont know how to get a Client object from the dispatch api so that I can > set interceptors like: > cxfClient.getInInterceptors().add(...); > > I found this link in this forum which suggests it should be very easy: > http://cxf.547215.n5.nabble.com/adding-features-and-or-interceptors-to-a-dynamic-jax-ws-dispatcher-client-td3200104.html > But after observing the interfaces for these classes and a few others, I am > unable to figure it out. Pls help. > > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/adding-interceptors-to-a-dynamic-jax-ws-dispatcher-client-tp5723001.html > Sent from the cxf-user mailing list archive at Nabble.com. -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
