2015-12-03 57 views
0

我希望websphere WAS 8.0.0.5將我的「Authorization:blabla」http-header添加到所有對服務的jax-ws客戶端請求中。我已經閱讀了很多主題,但什麼都不起作用。我在websphere上部署了一個jax-ws客戶端。我創建了自己的應用程序策略集並附加在我的服務上,並在HTTP傳輸的自定義屬性中使用我的授權HTTP標頭創建了常規客戶端策略集綁定。我附加了我的策略並綁定到了我的客戶服務,但它不起作用。每次我得到以下例外︰如何將http-headers添加到websphere(WAS)上的所有結果jax-ws客戶端請求中?

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) 

我的問題是,我不能修改客戶端以編程方式插入我的標頭。有人可以解釋爲什麼websphere綁定不起作用?

感謝

回答

-1

您可以使用BindingProvider增加MessageContext.HTTP_REQUEST_HEADERS你需要什麼。

// 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); 

您也可以使用com.ibm.websphere.webservices.Constants.REQUEST_TRANSPORT_PROPERTIES作爲關鍵,它也應該可以正常工作。

查看更多: How request transport headers are sent by a JAX-WS Web services client application

+0

海報說,他們不能修改代碼,並尋求通過WebSphere綁定僅配置方式。 –

相關問題