WSDL太大时,JAX-WS客户端将挂起30秒 [英] JAX-WS client side is hanging for 30 secs when WSDL is too large

查看:84
本文介绍了WSDL太大时,JAX-WS客户端将挂起30秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对JAX-WS Web服务和Apache CXF有点陌生.我们正在开发一个简单的客户端-服务器系统,它们之间的通信是通过JAX-WS Web服务协议进行的.在服务器端,我们正在使用Apache CXF实现(由于使用了拦截器),在客户端,这是常规的参考实现( jax-ws-rt ).

I'm a little new to JAX-WS Webservices and Apache CXF. We're developing a simple client-server system, and the communication between them is through JAX-WS web service protocol. On the server side, we're using Apache CXF implementation (because of using interceptors), on the client side it is the normal reference implementation (jax-ws-rt).

我的问题如下:当客户端首先创建服务时:

My problem is the following: when the client creates the service first:

service = Service.create(uri.toURL(), new QName(targetNamespace, serviceName));

然后通常将GET请求发送到服务器,以获取和处理WSDL.首先是这样的:

then it normally sends GET requests to the server, in order to get and process the WSDL. First is something like this:

GET .../services/ws/mainservice?wsdl

然后紧接

GET .../services/ws/mainservice?wsdl=mainservice.wsdl

到目前为止,太好了.第三个请求是使用SOAP的普通HTTP POST请求,调用了客户端调用的函数.

So far, so good. The third requests is the normal HTTP POST request, using SOAP, invoking the function what the client calls.

一切正常,直到WSDL太大为止.我可以从网络浏览器中查看尺寸,例如,使用上面的两个GET链接.当第二个GET请求的响应达到100K大小(浏览器中的XML响应)时,由于在Web服务接口中声明了太多的函数,则发生以下情况:在第二个GET期间,客户端挂起了大约30秒请求,然后一切正常,函数运行.

Everything worked fine until the WSDL got too large. I can check out the size from a web browser e.g., using the two GET links above. When the response for the second GET request reaches the 100K size (the XML response in the browser), because there are too many functions declared in the web service interface, then the following happens: the client is hanging about 30 secs during the second GET request, and then everything is fine, the function runs.

我调试了一下,在这种情况下,该点被阻止了,它调用时位于 RuntimeWSDLParser.java 中的createReader()函数中.

I debugged, which point is blocked in that case, it is in the RuntimeWSDLParser.java, createReader() function, when it calls:

private static XMLStreamReader createReader(URL wsdlLoc, Class<Service> serviceClass) throws IOException, XMLStreamException {
InputStream stream;
try {
    stream = wsdlLoc.openStream();
} catch (IOException io) {

}

此文件位于客户端的jax-ws-rt.jar中.

and this file is in the jax-ws-rt.jar on the client side.

奇怪的是(至少对我来说,但我并不是很熟悉),如果我使用调试器到达这一行并立即越过,那大约是30秒的阻塞.如果我等待25秒,然后我才走过去,则仅5秒.因此,似乎有一个柜台可以将其挂在某处.

The strange thing is (at least for me, but I'm not really familiar with it) that if I reach to this row with the debugger, and immediately step over, then it is about 30 secs of blocking. If I wait 25 secs, and just then I step over, then it is 5 secs only. So it seems there is a counter for this hanging somewhere.

另一件事:仅当我使用localhost连接时,才会出现此问题.如果我尝试使用与另一台计算机不同的客户端,并使用内部IP地址,则不会出现阻塞.同样,当我尝试使用TCPMon并重定向端口时,也是​​如此.

Another thing: this problem is only occurs when I use localhost connections. If I try to use a differenc client from another computer, and use inner IP address, there is no blocking. Nor when I try to use TCPMon and I redirect the port.

我希望我足够具体.任何帮助将不胜感激,我在这个问题上停留了好几天.预先感谢!

I hope I was specific enough. Any help would be appreciated, I'm stuck at this problem for days. Thanks in advance!

推荐答案

今天您很幸运!有两种选择:

Today you're in luck! There is two options:

  1. 在本地使用WSDL文档文件

    将WSDL文档文件和方案文件的副本保存到您的项目中.

  1. Use a WSDL document file locally

    Save a copy of the WSDL document file and the schemma files to your project.

ClassLoader classloader = Thread.currentThread().getContextClassLoader();
URL wsdlLocation = classloader.getResource("MyHelloService.wsdl");
QName serviceName= new QName("http://test.com/", "MyHelloService");

MyHelloService service = new MyHelloService(wsdlLocation, serviceName);
service.sayHello("Test");

  • 没有WSDL文档文件

    QName qname = new QName("http://thenamespace", "FooService");
    FooService service = new FooService(null, qname); // null for ignore WSDL
    Foo port = service.getFooPort();
    BindingProvider bindingProvider = (BindingProvider) port;
    bindingProvider.getRequestContext()
        .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
        "http://foo.com/soap/fooBean");
    
    // Use the service
    Object obj = port.doSomething(param);
    


  • 另请参阅:


    See also:

    这篇关于WSDL太大时,JAX-WS客户端将挂起30秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆