在 WebSphere Application Server 8.5 中禁用 JAX-WS 客户端的分块传输编码

Disable chunked transfer-encoding for JAX-WS Client in WebSphere Application Server 8.5

在 IBM WebSphere Application Server (WAS) V8.5.5.11 之上运行的 Web 应用程序中,有一个 JAX-WS 客户端(使用 WAS 内置的 JAX-WS 组件)调用外部网络服务。

对于 HTTP 正文大于 32 KB 的任何 Web 服务调用,WAS 将使用分块传输编码。不幸的是,外部网络服务无法处理分块传输编码,并且会出错。

如何在 WAS JAX-WS 客户端代码中禁用分块传输编码?

您需要创建一个 SOAP JAX-WS 处理程序并重写 handleMessage 方法以添加一个 http header,如下所示:

public boolean handleMessage(SOAPMessageContext smc) {
  ctx.put(HTTPConstants.CHUNKED, "false");
  return true;
}

这很简单,只需为处理程序创建一个 class 并创建一个简单的 xml 文件来声明它 检查 https://jax-ws.java.net/articles/handlers_introduction.htmlor http://www.mkyong.com/webservices/jax-ws/jax-ws-soap-handler-in-client-side/

我找不到以编程方式为 WAS 8.5 的内置 JAX-WS 禁用分块传输编码的方法。5.x。但我确实找到了一种通过 WAS "Administrative Console" 禁用它的方法。

基本上,您需要复制 "WSHTTPS default" 策略集,并修改 "HTTP transport" 策略以取消选中 "Enable chunked transfer encoding" 的框。然后将此自定义策略集分配给您的服务客户端。

可在 https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.nd.doc/ae/twbs_wsspspthttp.html

找到详细说明

您可以应用策略集并选择禁用分块。