cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brady Adams <j.brady.ad...@gmail.com>
Subject Need Help Please... - Adding ID in the Header
Date Wed, 09 Oct 2013 09:46:56 GMT
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...

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message