[英]JAX-WS RI cannot change charset=utf-8
I am using the JAX-WS RI, with files that have been auto-geenrated by Netbeans via File > Web Service and then entering the WSDL. 我使用的是JAX-WS RI,其文件由Netbeans通过File> Web Service自动进行了整理,然后输入WSDL。
The problem I am having is that the JAX-WS RI always attaches this header to the request: 我遇到的问题是JAX-WS RI总是将此标头附加到请求:
Content-Type: application/soap+xml; charset=utf-8;action="urn:getOrganization"
However our web server does not accept charset=utf-8
, it wants charset=UTF-8
. 但是,我们的Web服务器不接受
charset=utf-8
,它需要charset=UTF-8
。
How can I change this using the JAX-WS RI? 如何使用JAX-WS RI更改此设置?
If this cannot be done, then are there other options available which ultimately lead to sending charset=UTF-8
? 如果无法做到这一点,那么还有其他可用选项最终导致发送
charset=UTF-8
吗?
Maybe a Handler may do the trick? 也许处理程序可以解决问题?
public class EnforceUppercaseUtf8MessageHandler implements SOAPHandler<SOAPMessageContext> {
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound.booleanValue()) {
try {
context.getMessage().setProperty(SOAPMessage.CHARACTER_SET_ENCODING,
"UTF-8");
}
catch (SOAPException e) {
throw new RuntimeException(e);
}
}
return true;
}
And register the handler: 并注册处理程序:
BindingProvider bindProv = (BindingProvider) service;
List<Handler> handlerChain = bindProv.getBinding().getHandlerChain();
handlerChain.add(new EnforceUppercaseUtfMessageHandler ());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.