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

Cannot add headers to request from Dispatch client in async mode -- ThreadLocal issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.4
    • 2.1.5
    • JAX-WS Runtime
    • None
    • JDK 1.6.0_10

    • Advanced

    Description

      org.apache.cxf.jaxws.DispatchImpl extends org.apache.cxf.jaxws.BindingProviderImpl, which has a requestContext field:

      protected ThreadLocal <Map<String, Object>> requestContext =
      new ThreadLocal<Map<String, Object>>();

      Because the request context is in a ThreadLocal, changes made to it are not visible when you invoke the service via DispatchImpl's invokeAsync method.

      For example:

      dispatch.getRequestContext().put(
      BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE );
      dispatch.getRequestContext().put(
      BindingProvider.SOAPACTION_URI_PROPERTY, "uri:myAction" );

      // If you call it this way, no SOAPAction header, verified by Wireshark:
      Response<StreamSource> response = dispatch.invokeAsync( request );

      // But if you call it this way, you get the header
      StreamSource result = dispatch.invoke( request );

      I can package up a test case if anyone thinks it would help fix this. Personally I know very little about CXF's internals, or the JAX-WS specs, but I can do whatever necessary to help.

      Attachments

        Issue Links

          Activity

            People

              dkulp Daniel Kulp
              andrewclegg Andrew Clegg
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: