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

jaxws Provider doesn't allow override of outbound ws addressing headers

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      I have a jaxws Provider configured to do WS-Addressing and the defaults seem to work fine. However, if I try to override some of the WS-Addressing headers in the MessageContext, it gets ignored. I've tried the following :

      AddressingProperties wsaServer = new AddressingPropertiesImpl(); AttributedURIType aut = new AttributedURIType(); aut.setValue("urn:get:some"); wsaServer.setAction(aut); messageContext.put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, wsaServer);

      But the Action header sent in the response is the default from the WSDL, not my override value. Am I doing something wrong or this never worked? I've tried doing:
      messageContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND)

      But that returns null, so I've been using the put instead. I tried overriding the messageId as well, but that didn't work either.

      Debugging through the code illustrates that you can't just set this property on the MessageContext object for the Provider, you must set it on the outbound message object, like this:
      ((org.apache.cxf.jaxws.context.WrappedMessageContext)messageContext).getWrappedMessage().getExchange().getOutMessage().put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, wsaServer);

      So the working code for me becomes something like:
      AddressingProperties wsaServer = new AddressingPropertiesImpl(); AttributedURIType aut = new AttributedURIType(); aut.setValue("urn:get:some"); wsaServer.setAction(aut); ((org.apache.cxf.jaxws.context.WrappedMessageContext)messageContext).getWrappedMessage().getExchange().getOutMessage().put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, wsaServer);

      I've tried overriding the message id and the action headers, both were successful.

      Dan suggested the following fix in ContextUtils. Change these lines:
      AddressingPropertiesImpl maps =
      (AddressingPropertiesImpl)message.get(mapProperty);
      if (maps != null) {
      LOG.log(Level.FINE, "current MAPs

      {0}", maps);
      }
      to:
      AddressingPropertiesImpl maps =
      (AddressingPropertiesImpl)message.get(mapProperty);
      if (maps == null && isOutbound && !isRequestor) { maps = (AddressingPropertiesImpl)message.getExchange().getInMessage().get(mapProperty); }
      if (maps != null) {
      LOG.log(Level.FINE, "current MAPs {0}

      ", maps);
      }

      I've tested this and it is successful with just the expected messageContext.put() call. Thanks Dan!

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            jpangburn Jesse Pangburn
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: