2

I am attempting to set a custom header on an outbound SOAP request using JAX-WS on WebSphere 8.5.5.2. The BindingProvider in the method below is obtained via JNDI for a service declared with a @ServiceRef annotation.

void setHeader(BindingProvider provider, String name, String value) {
    Map<String, Object> context = provider.getRequestContext();
    Map<String, List<String>> headers = null;

    if (context.containsKey(MessageContext.HTTP_REQUEST_HEADERS)) {
        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);
    }

    headers.put(name, Arrays.asList(value));
}

They key here, I think, is related to WebSphere. If I instead put the HTTP headers into an IBM-specific entry of the context:

com.ibm.websphere.webservices.Constants.REQUEST_TRANSPORT_PROPERTIES

the headers are properly placed into the SOAP HTTP request. Note that in case, the value is not wrapped inside a List instance.

Has anyone successfully implemented this solution on WebSphere using MessageContext.HTTP_REQUEST_HEADERS?

Michael Edgar
  • 350
  • 3
  • 12

1 Answers1

0

lease follow below link, it has samples:

http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/twbs_cookiejaxws.html?lang=en

Please follow above link, it has samples.

Iris Ding
  • 164
  • 2
  • 5
  • Thanks for the feedback. However, the examples on that page use the IBM value from `com.ibm.websphere.webservices.Constants.REQUEST_TRANSPORT_PROPERTIES`. I'd like to avoid that and use `MessageContext.HTTP_REQUEST_HEADERS` if possible. – Michael Edgar Nov 10 '15 at 17:38