Java 获取​;传输编码=在soap ws调用中分块而不是内容长度

Java 获取​;传输编码=在soap ws调用中分块而不是内容长度,java,web-services,http,soap,Java,Web Services,Http,Soap,我试图从java调用两个soap ws和。当我从两个不同的java线程调用这些ws时,它被成功调用,但当尝试调用同一个线程时,第一个调用成功,第二个调用卡住。我可以在日志中看到这两个请求 我在服务器上检查了tcp转储,可以看到对于第一个请求,所有的头参数都设置正确,但在第二个调用中,而不是在内容长度获取transfer encoding=chunked 第一个ws-call标题-2018年2月15日上午9:59:40[8] 内容长度=639内容类型=文本/xml;charset=UTF-8 Ac

我试图从java调用两个soap ws和。当我从两个不同的java线程调用这些ws时,它被成功调用,但当尝试调用同一个线程时,第一个调用成功,第二个调用卡住。我可以在日志中看到这两个请求

我在服务器上检查了tcp转储,可以看到对于第一个请求,所有的头参数都设置正确,但在第二个调用中,而不是在内容长度获取transfer encoding=chunked

第一个ws-call标题-2018年2月15日上午9:59:40[8]
内容长度=639内容类型=文本/xml;charset=UTF-8 Accept=/Host=test102.com用户代理=Apache CXF 2.7.11 SOAPAction=“Trackem.Web.Services/ReserveServiceTime”代理连接=保持活动状态

第二个ws-call标题-2018年2月15日上午10:01:11[9]
传输编码=分块内容类型=文本/xml;字符集​​=UTF-8 Accept=/Host=test102.com
用户代理=Apache CXF 2.7.11 SOAPAction=“Trackem.Web.Services/CreateOrUpdateTask” 代理连接=保持有效下午5:05

请帮助我理解为什么第二次呼叫不能正常工作

这是我的JavaWS方法-

public P getPort(final Class<P> serviceEndpointInterface, final String ascNode) throws MalformedURLException{

final Bus currThreadBus = BusFactory.getThreadDefaultBus();
ClassLoader originalThreadClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader busFactoryClassLoader = BusFactory.class.getClassLoader();

try {
    Thread.currentThread().setContextClassLoader(busFactoryClassLoader);
    BusFactory.setThreadDefaultBus(BusFactory.newInstance().createBus());

    QName qname = new QName(nameSpace, strQName);

    Service service = Service.create(qname);

    P port = null;

    if (CommonUtil.isEmpty(portName)) {
        port = service.getPort(serviceEndpointInterface);
    } else {
        QName portQname = new QName(nameSpace, portName);
        port = service.getPort(portQname, serviceEndpointInterface);
    }

    BindingProvider bp = (BindingProvider) port;
    // Timeout in millis
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceURL);
    bp.getRequestContext().put(Message.CONNECTION_TIMEOUT, Integer.parseInt(connectTimeout));
    bp.getRequestContext().put(Message.RECEIVE_TIMEOUT, Integer.parseInt(requestTimeout));

    final Client client = ClientProxy.getClient(port);
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    client.getInInterceptors().add(new LoggingInInterceptor());

    //Add proxy server details if configured in ASC
    if(!CommonMethods.isEmpty(proxyHost) && !CommonMethods.isEmpty(proxyPort))
    {
        HTTPConduit http = (HTTPConduit) ClientProxy.getClient(port).getConduit();

        http.getClient().setProxyServer(proxyHost);
        http.getClient().setProxyServerPort(Integer.parseInt(proxyPort));

        if(!CommonMethods.isEmpty(proxyUsername) && !CommonMethods.isEmpty(proxyPassword))
        {
            http.getProxyAuthorization().setUserName(proxyUsername);
            http.getProxyAuthorization().setPassword(proxyPassword);
        }
    }
    return port;
}finally {
    BusFactory.setThreadDefaultBus(currThreadBus);
    Thread.currentThread().setContextClassLoader(originalThreadClassLoader);
}}
public P getPort(最终类

serviceEndpointInterface,最终字符串ascNode)引发错误的FormedUrlexception{ 最终总线currThreadBus=BusFactory.getThreadDefaultBus(); ClassLoader originalThreadClassLoader=Thread.currentThread().getContextClassLoader(); ClassLoader busFactoryClassLoader=BusFactory.class.getClassLoader(); 试一试{ Thread.currentThread().setContextClassLoader(busFactoryClassLoader); setThreadDefaultBus(BusFactory.newInstance().createBus()); QName QName=新的QName(名称空间,strQName); 服务=服务.创建(qname); P端口=空; if(CommonUtil.isEmpty(portName)){ 端口=service.getPort(serviceEndpointInterface); }否则{ QName portQname=新的QName(名称空间,端口名称); port=service.getPort(portQname,serviceEndpointInterface); } BindingProvider bp=(BindingProvider)端口; //超时(毫秒) bp.getRequestContext().put(BindingProvider.ENDPOINT\u ADDRESS\u属性,serviceURL); bp.getRequestContext().put(Message.CONNECTION_TIMEOUT,Integer.parseInt(connectTimeout)); get requestcontext().put(Message.RECEIVE_TIMEOUT,Integer.parseInt(requestTimeout)); 最终客户端=ClientProxy.getClient(端口); client.getOutiterCeptors().add(新的LoggingOutiterCeptor()); client.getInInterceptors().add(新的logginInterceptor()); //添加代理服务器详细信息(如果在ASC中配置) 如果(!CommonMethods.isEmpty(proxyHost)和&!CommonMethods.isEmpty(proxyPort)) { httpconductor http=(httpconductor)ClientProxy.getClient(port.getconductor(); http.getClient().setProxyServer(proxyHost); http.getClient().setProxyServerPort(Integer.parseInt(proxyPort)); 如果(!CommonMethods.isEmpty(proxyUsername)和&!CommonMethods.isEmpty(proxyPassword)) { http.getProxyAuthorization().setUserName(proxyUsername); http.getProxyAuthorization().setPassword(proxyPassword); } } 返回端口; }最后{ BusFactory.setThreadDefaultBus(currThreadBus); Thread.currentThread().setContextClassLoader(originalThreadClassLoader); }}

我通过在HTTP客户端中禁用区块传输解决了这个问题。 http.getClient().setAllowChunking(false)


我想,问题出在我的代理服务器上,这根本没有帮助。