You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by fenix2 <zk...@gmail.com> on 2016/01/18 19:59:50 UTC
All previous soap headers in response message
When I add SOAP Header to response message, the previous headers are added
to. I use the same interceptor for responses (endpoint) and requests
(client) and it happened only in response message. What can cause that
previous headers remains in response messages?
--
View this message in context: http://cxf.547215.n5.nabble.com/All-previous-soap-headers-in-response-message-tp5764870.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: All previous soap headers in response message
Posted by fenix2 <zk...@gmail.com>.
add 1.) I now about this CXF possiblity but I need very specific MessageID
and it is bound with message content.
add 2.) You are right. Thank you.
--
View this message in context: http://cxf.547215.n5.nabble.com/All-previous-soap-headers-in-response-message-tp5764870p5765192.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: All previous soap headers in response message
Posted by Andrei Shakirin <as...@talend.com>.
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:zkatyfenix@gmail.com]
> Sent: Sonntag, 24. Januar 2016 16:31
> To: users@cxf.apache.org
> 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.
RE: All previous soap headers in response message
Posted by fenix2 <zk...@gmail.com>.
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.
RE: All previous soap headers in response message
Posted by Andrei Shakirin <as...@talend.com>.
Hi,
Could you post a code snapshot adding the SOAP Header from your interceptor?
Regards,
Andrei
> -----Original Message-----
> From: fenix2 [mailto:zkatyfenix@gmail.com]
> Sent: Montag, 18. Januar 2016 20:00
> To: users@cxf.apache.org
> Subject: All previous soap headers in response message
>
> When I add SOAP Header to response message, the previous headers are
> added to. I use the same interceptor for responses (endpoint) and requests
> (client) and it happened only in response message. What can cause that
> previous headers remains in response messages?
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/All-previous-
> soap-headers-in-response-message-tp5764870.html
> Sent from the cxf-user mailing list archive at Nabble.com.