You cannot changed the endpoint address within a handler. By then it’s too late, we’ve already connected to the server. You need to set the BindingProvider.ENDPOINT_ADDRESS_PROPERTY on the client proxy prior to making the invocation. Alternatively, a CXF interceptor that runs VERY VERY early in the chain can set the address via the internal Message.ENDPOINT_ADDRESS key.
Dan > On May 31, 2017, at 6:44 AM, Me Self <[email protected]> wrote: > > Hi All > > I'm migrating from com.sun.* implementation of jax-ws to CXF and > experiencing a problem that setting the endpoint address from inside af > SOAPHandler no longer works - code shown below. CXF doesnt use the endpoint > set with BindingProvider.ENDPOINT_ADDRESS_PROPERTY instead it uses the > endpoint found in the WSDL file. Is there some alternative way to set it > from inside the handler (for various reasons I dont want a solution the > sets it on the port before the handler)? > > > public class MyHandler implements SOAPHandler<SOAPMessageContext> { > > > @Override > > public boolean handleMessage(SOAPMessageContext messageContext) { > > ... > messageContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, > endpoint); > > > Looking at the key/value pais inside the MessageContext some list the > endpoint from the WSDL referencing localhost:6500 while others list the > endpoint it set in the code above. The "javax.xml.ws.service.endpoint.address" > key is the one I would expect to determine the endpoint officially: > > 2017-05-31 12:22:16 DEBUG MyHandler:21 - org.apache.cxf.transport.Conduit > 017-05-31 12:22:16 DEBUG MyHandler:24 - conduit: class > org.apache.cxf.transport.http.HTTPConduit1394932896target: > http://localhost:6500/ <http://localhost:6500/Insuran>Bla/Bla > > 2017-05-31 12:22:16 DEBUG MyHandler:21 - org.apache.cxf.message. > Message.ENDPOINT_ADDRESS > 2017-05-31 12:22:16 DEBUG MyHandler:24 - http://thecorrectaddress/Bla/Bla > <http://osb01-dev3:6501/Insurance/LossOfOccupationalCapacity> > <http://osb01-dev3:6501/Insurance/LossOfOccupationalCapacity> > > 2017-05-31 12:22:16 DEBUG MyHandler:21 - javax.xml.ws.service.endpoint. > address > 2017-05-31 12:22:16 DEBUG MyHandler:24 - http://thecorrectaddress/Bla/Bla > <http://osb01-dev3:6501/Insurance/LossOfOccupationalCapacity> > > 2017-05-31 12:22:16 DEBUG MyHandler:21 - http.connection > 2017-05-31 12:22:16 DEBUG MyHandler:24 - sun.net.www.protocol.http. > HttpURLConnection:http://localhost:6500/Insurance/LossOfOccupationalCapacity > <http://osb01-dev3:6501/Insurance/LossOfOccupationalCapacity> > <http://osb01-dev3:6501/Insurance/LossOfOccupationalCapacity> > .... -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
