有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

IntelliJ评估中SOAP的RequestContext上的java SOAPFaultException

在IntelliJ中调试期间,我在RequestContext对象中计算表达式(或在调试控制台中添加监视)后得到SOAPFaultException。更具体地说,错误是:

javax.xml.ws.soap.SOAPFaultException: Server did not recognize the value of HTTP Header SOAPAction: .

为什么会这样


共 (1) 个答案

  1. # 1 楼答案

    发生此错误的原因是类RequestContext的映射自定义实现。java是在jaxws rt(版本2.1.4)库中生成的。 自定义映射实现有一个回退机制,当变量“mapView.fallbackMap”为空时,回退循环中的标题“soapAction”将被清除。检查剪下的波纹管:

     /**
     * 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方法时,都会填充变量“mapView.fallbackMap”,例如“entrySet”或“size”方法。因此,每次我们调用“监视”或“评估”操作来调试IntelliJ IDEA中的RequestContext时,回退都由SOAP调用填充

    因此,该解决方案不用于在SOAP调用之前调试RequestContext,或确保在执行请求之前删除以下属性:

    ((BindingProvider) service).getRequestContext().remove("javax.xml.ws.soap.http.soapaction.uri")