Search code examples
javaweb-servicesjakarta-eewebspherejax-rpc

Custom http headers in JAX-RPC request not working in websphere 8


The below scenario is for IBM JDK and IBM JAX-RPC implementation.

The requirement is to send couple of customer header properties in JAX-RPC request with WebSphere as the container. I have the below code set in my client.

HashMap headers = new HashMap();
headers.put("fid-app","Test");
headers.put("someKey","someValue");
stub._setProperty(Constants.REQUEST_TRANSPORT_PROPERTIES, headers);

I tried to test the client from my machine (adding WebSphere thin client to the classpath) and I was able to see the http headers are being passed properly. Same code doesn't work when it is deployed in WebSphere container.

When i enabled trace logs in both my local testing and container testing, i was able to see that Websphere tries to get REQUEST_TRANSPORT_PROPERTIES property from ThreadLocal but HashMap is being returned through my local testing and null is being returned in the container.

What could be the reason for this issue? Do we need to set any additional properties in container to enable request transport headers?

Thanks.


Solution

  • Turns out that the problem was not related to JAX-RPC or WebSphere. We've been using a proxy class which uses hystrix to process the stub invocations. In my local testing, i had disabled hystrix, so it was working fine. In container environment where hystrix was enabled and the execution strategy was set as THREAD. So when the header parameters are set to stub, it is stored in a different thread than from which it was trying to retrieve when WebSphere tries to load them. That was the underlying problem. Switched to hystrix execution strategy SEMAPHORE and it worked fine.