Hi,

Please take a look at the faq here[1], that tell you how can you add a customer 
soap header

[1]http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest%2Fresponse%3F
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋



On 2013-10-9, at 下午5:46, Brady Adams wrote:

> Hi Team,
> 
> I am newbie to the Apache CXF. My requirement is to pass the Soap header
> and need to add a custom HTTP Header. Please help me.
> 
> As per my understanding first the Clients Out Interceptors sends the Out
> Message and it is received by the Server In Interceptors and the same is
> transported to the Service Out Interceptors and again to Client In
> Interceptors.
> 
> i.e. Client ----> Out  to  Server ----> IN        and Server ----> Out to
> Client ----> In
> 
> Please correct me if I am wrong.
> 
> So I have written a Client Out interceptor which extends
> AbstractPhaseInterceptor<Message> with interceptor Phase.SETUP and the code
> is as below, the MessageContext I am passing as a parameter in the Client
> Implementation.  As *ClientProxy.getClient(port).getOutInterceptors().add(new
> ClientOutInterceptor(msgCntxt));*
> 
> *public class ClientOutInterceptor extends
> AbstractPhaseInterceptor<Message> {
> 
>    private static Logger LOG =
> LoggerFactory.getLogger(ClientOutInterceptor.class);
> 
>    private MessageContext msgContext;
> 
>    public ClientOutInterceptor(MessageContext msgContext) {
>        super(Phase.SETUP);
>        this.msgContext = msgContext;
>    }
> 
>    @Override
>    public void handleMessage(Message message) throws Fault {
> 
>        List<Header> outHeaders = new ArrayList<Header>();
>        List<SoapHeader> inHeaders = (ArrayList<SoapHeader>)
> msgContext.get(IConstants.SOAP_HEADER);
>        for (Header header : inHeaders) {
>            outHeaders.add(new Header(header.getName(), header.getObject(),
> header.getDataBinding()));
>        }
>        message.put(IConstants.SOAP_HEADER, outHeaders);
>        message.put(IConstants.ATTACHMENTS,
> (Collection<Attachment>)msgContext.get(IConstants.ATTACHMENTS));
>    }
> }*
> 
> And my Service In Interceptor is extending
> AbstractPhaseInterceptor<Message> and the Interceptor Phase.RECEIVE and the
> code is as below,
> 
> *public class ServiceInInterceptor extends
> AbstractPhaseInterceptor<Message> {
> 
>    private static Logger LOG =
> LoggerFactory.getLogger(ServiceInInterceptor.class);
> 
>    public ServiceInInterceptor() {
>        super(Phase.RECEIVE);
>    }
> 
>    @Override
>    public void handleMessage(Message message) throws Fault {
> 
>     LOG.info(" ServiceInInterceptor "+message.get(IConstants.SOAP_HEADER));
> 
>    }
> }*
> 
> and I have configured this in the service side xml
> 
> *<cxf:bus>
>        <cxf:inInterceptors>
>            <ref bean="msgInInterceptor" />
>        </cxf:inInterceptors>
> </cxf:bus>*
> 
> But here I am not getting the messages in the Service In Interceptor and
> the same has to be transported to Service Out and to the Client In
> Interceptors, please can anyone help me how to do this. It will be of great
> help. We are in a very critical position to implement this.
> 
> Please help me on this regard.
> 
> Thanks in Advance,
> 
> Brady...

Reply via email to