There are kind of two parts to this: getting the header from the request and then setting it on the call to then next
Retrieve the soap headers from the incoming message - this can be done in one of two ways: a) If the header is part of the WSDL contract, it could likely be generated as a parameter onto the service. There would be a param with a WebParam annotation with header=true set. b) Have the WebServiceContext injected into the service and then grab the header list from that: List<Header> headers = ctx.getMessageContext().get(org.apache.cxf.headers.Header.HEADER_LIST); Once you have the header, you need to set it on the client for the outgoing message: ((BindingProvider)client).getRequestContext().put(org.apache.cxf.headers.Header.HEADER_LIST, headers); The trick hear is that you LIKELY need to create a new List<Header> and copy from the original list to the new list with new Header objects. The incoming headers are likely marked with an “IN” direction (since they are coming in) and may not get sent out on the client. Hope that helps! Dan > On Sep 4, 2015, at 10:19 AM, sivaraman <[email protected]> wrote: > > > Hi All, > I have a business flow as given below. > > Application1 >> CXF Service >> CXF Client >> Application 2 > > The Application1 calls a CXF Service with a SOAP Header. > The CXF Service on receipt of the Request will perform some logic and then > call Application 2 using the CXF Client. > > While calling the Application 2, the CXF client should use the same SOAP > Header that the Application1 sent to the CXF Service. > > How can this be done in CXF? > > > > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/Passing-SOAP-Header-from-one-Service-to-another-in-CXF-tp5760783.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
