![](/img/trans.png)
[英]How to add http-headers to all outcome jax-ws client's requests on websphere(WAS)?
[英]How can HTTP headers be added to JAX-WS requests in WebSphere 8.5?
我試圖在WebSphere 8.5.5.2上使用JAX-WS在出站SOAP請求上設置自定義標頭。 下面的方法中的BindingProvider是通過JNDI獲得的,用於使用@ServiceRef批注聲明的服務。
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));
}
我認為,這里的關鍵與WebSphere有關。 如果我改為將HTTP標頭放入上下文的IBM特定條目中:
com.ibm.websphere.webservices.Constants.REQUEST_TRANSPORT_PROPERTIES
標頭已正確放置在SOAP HTTP請求中。 請注意,以防萬一,該值未包裝在List實例內。
有沒有人使用MessageContext.HTTP_REQUEST_HEADERS
在WebSphere上成功實現此解決方案?
租賃請點擊以下鏈接,其中包含示例:
請點擊上面的鏈接,其中包含示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.