在IntelliJ中进行调试期间,在SOAPFaultException
对象中评估表达式(或在调试控制台中添加Watching)后,我得到了RequestContext
。更具体地说,该错误显示为:
javax.xml.ws.soap.SOAPFaultException: Server did not recognize the value of HTTP Header SOAPAction: .
为什么会这样?
答案 0 :(得分:0)
由于在jaxws-rt(版本2.1.4)库中进行了RequestContext.java类的Map定制实现,因此发生此错误。 自定义地图实现具有一个后备机制,当变量“ mapView.fallbackMap”为空时,头名“ soapAction”在后备for循环中清晰可见。检查折断的波纹管:
/**
* Fill a {@link Packet} with values of this {@link RequestContext}.
*/
public void fill(Packet packet) {
if(mapView.fallbackMap==null) {
if (endpointAddress != null)
packet.endpointAddress = endpointAddress;
packet.contentNegotiation = contentNegotiation;
if (soapAction != null) {
packet.soapAction = soapAction;
}
if(!others.isEmpty()) {
packet.invocationProperties.putAll(others);
//if it is not standard property it deafults to Scope.HANDLER
packet.getHandlerScopePropertyNames(false).addAll(others.keySet());
}
} else {
Set<String> handlerScopePropertyNames = new HashSet<String>();
// fallback mode, simply copy map in a slow way
for (Entry<String,Object> entry : mapView.fallbackMap.entrySet()) {
String key = entry.getKey();
if(packet.supports(key))
packet.put(key,entry.getValue());
else
packet.invocationProperties.put(key,entry.getValue());
//if it is not standard property it deafults to Scope.HANDLER
if(!super.supports(key)) {
handlerScopePropertyNames.add(key);
}
}
if(!handlerScopePropertyNames.isEmpty())
packet.getHandlerScopePropertyNames(false).addAll(handlerScopePropertyNames);
}
}
此外,每次在Map中创建自定义实现不支持的方法(例如,“ entrySet”或“ size”方法)时,都会填充变量“ mapView.fallbackMap”。因此,每次我们调用“ Watch”或“ Evaluate”操作来调试IntelliJ IDEA中的RequestContext时,都会因SOAP调用而中断。
因此,该解决方案不会在SOAP调用之前用于调试RequestContext,或者确保在执行请求之前确保删除以下属性:
((BindingProvider) service).getRequestContext().remove("javax.xml.ws.soap.http.soapaction.uri")