cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Freeman Fang <freeman.f...@gmail.com>
Subject Re: Need Help Please... - Adding ID in the Header
Date Thu, 10 Oct 2013 11:22:11 GMT
Hi,

Scenario #2 is how the message flow works
-------------
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-10, at 下午7:05, Brady Adams wrote:

> Hi Freeman Fang,
> 
> Thank you so much for your help and time for dropping this email in between
> your other commitments. I am trying the same way... but my doubt was how
> the flow is... I hope the first one is the right and is there the second
> scenario do exists, in case if it exists in what case it is...
> 
> Scenario # 1
> 
> 1. Service In Interceptor to
> 2. Client Out Interceptor to
> 3. Client In Interceptor to
> 4. Service Out Interceptor
> 
> or
> 
> Scenario # 2
> 
> 1. Client Out Interceptor to
> 2. Service In Interceptor to
> 3. Service Out Interceptor to
> 4. Client In Interceptor
> 
> Thanks you once again for your help.
> 
> Brady...
> 
> 
> On 10 October 2013 16:45, Freeman Fang <freeman.fang@gmail.com> wrote:
> 
>> 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...
>> 
>> 


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