Hi,

Some points:
1. Why you proceed wsa:MessageID header manually? CXF supports WS-Addressing 
protocol, you just need to activate it using CXF feature or ws-policy 
http://cxf.apache.org/docs/ws-addressing.html .
2. Your code gets header list from the request context and adds new header with 
message id. I guess, if this code will be called multiple times in the same 
thread the headers will be accumulated. Adding header to newly created list 
should fix it.

Regards,
Andrei.

> -----Original Message-----
> From: fenix2 [mailto:[email protected]]
> Sent: Sonntag, 24. Januar 2016 16:31
> To: [email protected]
> Subject: RE: All previous soap headers in response message
> 
> Hi,
> 
> I found that the problem is not caused by my interceptor but the problem is
> in my service which creates message and adds wsa:MessageID. If I do not
> add MessageID to SOAP header, it works correctly. But if MessageID is
> added, all previous MessageID (and also other headers added by
> interceptor) are cumulated. The same problem (MessageID cumulating)
> occurs even without interceptor.
> 
> Snippet of class which sends messages where MessageID is cumulated from
> previous messages:
> 
> //@WebService generated by CXF (wsdl2java) @Inject private
> UpdateService updateService;
> 
> public void updatesSender(){
>     ((BindingProvider)
> updateService).getRequestContext().put("thread.local.request.context",
> "true");
>     String messageId = idGenerator.nextId();
>     try {
>         addSoapHeaderMassegeId((BindingProvider) updateService,
> messageId);
>     }
>     UpdateMessageType message = messageCreator.getMessage();  //creates
> message for sending
>     UpdateResponseHandler handler = new
> UpdateResponseHandler(message, messageId);
>     updateService.updateAsync(message, handler); }
> 
> public static void addSoapHeaderMassegeId(BindingProvider port, String
> messageID) throws JAXBException {
>     List<Header> headers = getHeaders(port);
>     Header messageIDHeader = new Header(new
> QName("http://www.w3.org/2005/08/addressing";, "MessageID", "wsa"),
> messageID, new JAXBDataBinding(String.class));
>       headers.add(messageIDHeader);
>       port.getRequestContext().put(Header.HEADER_LIST, headers); }
> 
> public static List<Header> getHeaders(BindingProvider port) {
>     Map<String, Object> messageContext = port.getRequestContext();
>     if (messageContext == null) {
>         return null;
>     }
>     List<Header> headers = CastUtils.cast((List<?>)
> messageContext.get(Header.HEADER_LIST));
>     if (headers == null) {
>         return new ArrayList<Header>();
>     }
>     return headers;
> }
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/All-previous-
> soap-headers-in-response-message-tp5764870p5765098.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to