You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Jimmy Praet (JIRA)" <ji...@apache.org> on 2018/03/20 10:13:00 UTC

[jira] [Created] (CXF-7682) context.get(MessageContext.HTTP_REQUEST_HEADERS) returns always null for client

Jimmy Praet created CXF-7682:
--------------------------------

             Summary: context.get(MessageContext.HTTP_REQUEST_HEADERS) returns always null for client
                 Key: CXF-7682
                 URL: https://issues.apache.org/jira/browse/CXF-7682
             Project: CXF
          Issue Type: Bug
          Components: JAX-WS Runtime
            Reporter: Jimmy Praet


I have a client-side LogicalHandler that adds some HTTP headers and am noticing it causes the existing SOAPAction HTTP header (already added automatically by the JAX-WS runtime) to be removed.

My handler code looks like this:
{code:java}
public boolean handleMessage(LogicalMessageContext context) {
  Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
  if (outbound) {
    Map<String, List<String>> headers =
        (Map<String, List<String>>) context.get(MessageContext.HTTP_REQUEST_HEADERS);
    if (headers == null) {
      headers = new HashMap<String, List<String>>();
      context.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
    }
    for (Map.Entry<String, String> entry : Tracer.getEntries().entrySet()) {
      headers.put(entry.getKey(), Collections.singletonList(entry.getValue()));
    }
  }
  return true;
}
{code}
I had a quick look at the code and noticed the [LogicalMessageContextImpl#get(Object) |https://github.com/apache/cxf/blob/a36af6323505211479c875fb9923cc6dcbc6ac95/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageContextImpl.java#L53] always returns null on the client side (isRequestor() = true).

So my handler will create a new header map and put it on the context, which is internally mapped to key "org.apache.cxf.message.Message.PROTOCOL_HEADERS" [here|https://github.com/apache/cxf/blob/master/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java#L462].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)