Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7682

context.get(MessageContext.HTTP_REQUEST_HEADERS) always returns null for client

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1.16, 3.2.5
    • Component/s: JAX-WS Runtime
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      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:

      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;
      }
      

      I had a quick look at the code and noticed the LogicalMessageContextImpl#get(Object) 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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jpraet Jimmy Praet
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: