0

I want websphere WAS 8.0.0.5 to add my "Authorization:blabla" http-header to all my jax-ws client request to the service. I've read a lot of topics, but anything doesn't work. I have a jax-ws client deployed on websphere. I've created my own application poliicy set and attached on my service and created General client policy set binding with my authorization HTTP-header in custom properties of HTTP-transport. I attached my policy and binding to my client service, but it doesn't work. Every time I get the following exception:

00000023 SOAPOverHTTPS E   WSWS7263E: The following exception occured: org.apache.axis2.AxisFault: HTTP ( 401 ) Unauthorized address : http://192.168.32.120:8280/hello/1/1
    at com.ibm.ws.websvcs.transport.http.SOAPOverHTTPSender.processStatusCode(SOAPOverHTTPSender.java:3659)
    at com.ibm.ws.websvcs.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:595)
    at com.ibm.ws.websvcs.transport.http.HTTPTransportSender.invoke(HTTPTransportSender.java:366)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:544)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:578)
    at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:127)
    at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:93)
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:390)
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:188)
    at $Proxy60.sayHello(Unknown Source)
    at com.lexa.HelloClient.doTest(HelloClient.java:36)
    at com.lexa.HelloClient.init(HelloClient.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)

My problem is that I cannot modify client to insert my header programmatically. Can somebody explain why websphere binding doesn't work?

Thanks

abrikos
  • 1
  • 2

1 Answers1

-1

You can use BindingProvider adding to MessageContext.HTTP_REQUEST_HEADERS what you need.

// Set up the request headers map.
Map<String, Object> requestHeaders = new HashMap<String, Object>();
requestHeaders.put("MyHeader1", "This is a string value");
requestHeaders.put("MyHeader2", new Integer(33));
requestHeaders.put("MyHeader3", new Boolean(true));

BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders);

You may also use com.ibm.websphere.webservices.Constants.REQUEST_TRANSPORT_PROPERTIES as key, it should works fine too.

See more: How request transport headers are sent by a JAX-WS Web services client application

antoniodvr
  • 1,259
  • 1
  • 14
  • 15