JAX-WS 客户端 - 如何处理"文本/纯文本"响应?



我正在使用jaxws客户端访问web服务。该服务似乎正在返回内容类型为"text/plain"而不是"text/xml"的响应,这导致我的客户端出现以下异常

com.sun.xml.internal.ws.server.UnsupportedMediaException: 
Unsupported Content-Type: text/plain Supported ones are: [text/xml]

我在创建端口时尝试了以下操作

port.getRequestContext().put(MessageContext.HTTP_RESPONSE_HEADERS, 
Collections.singletonMap("Content-Type",
                Collections.singletonList("text/plain")));

但这没有任何效果。

据我所知(通过查看源代码),我认为与JDK 1.6捆绑的JAX-WS RI 2.1不支持"text/plain",除非启用了MTOM。

最新更新