当WSDL太大时,JAX

编程入门 行业动态 更新时间:2024-10-17 02:46:19
当WSDL太大时,JAX-WS客户端挂起30秒(JAX-WS client side is hanging for 30 secs when WSDL is too large)

我是JAX-WS Webservices和Apache CXF的新手。 我们正在开发一个简单的客户端 - 服务器系统,它们之间的通信是通过JAX-WS Web服务协议实现的。 在服务器端,我们使用的是Apache CXF实现(因为使用了拦截器),在客户端它是正常的参考实现( jax-ws-rt )。

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

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

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

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

然后立即

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

到现在为止还挺好。 第三个请求是正常的HTTP POST请求,使用SOAP调用客户端调用的函数。

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

我调试了,在这种情况下阻塞了哪一点 ,它在RuntimeWSDLParser.java ,createReader()函数中,当它调用时:

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中。

奇怪的是(至少对我来说,但我并不熟悉它),如果我用调试器到达这一行,并立即跳过,那么大约30秒的阻塞。 如果我等待25秒,然后我就跳过,那么它只有5秒钟。 因此,似乎有一个计数器悬挂在某个地方。

另一件事:这个问题只发生在我使用localhost连接时。 如果我尝试使用另一台计算机的differenc客户端,并使用内部IP地址,则没有阻塞。 当我尝试使用TCPMon并且我重定向端口时也是如此。

我希望我足够具体。 任何帮助将不胜感激,我已经坚持这个问题好几天了。 提前致谢!

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));

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

and then immediately after

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

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

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.

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) { }

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

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.

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!

最满意答案

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

在本地使用WSDL文档文件

将WSDL文档文件和schemma文件的副本保存到项目中。

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);

也可以看看:

在没有WSDL合同的情况下开发消费者使用Java 6和JAX-WS使用Web服务 加载Java属性文件

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

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");

Without a WSDL document file

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:

Developing a Consumer Without a WSDL Contract. Consuming a Web Service with Java 6 and JAX-WS Loading Java Properties Files

更多推荐

本文发布于:2023-04-29 01:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:太大   WSDL   JAX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!