使用 axis1.4 时未考虑超时

发布于 2024-12-09 05:14:54 字数 299 浏览 0 评论 0原文

我在初始化 Web 服务存根时设置超时,甚至在调用之前使用 getTimeout() 记录它以确保它已设置,但无论设置的超时值如何,调用都会完成。这有可能是一个错误还是我在这里遗漏了一些东西?

下面是我执行此操作的代码:

proxy = new DCPControllerWSPortTypeProxy();
proxy.setEndpoint(endpoint);            
((Stub)proxy.getDCPControllerWSPortType()).setTimeout(120000);

I'm setting the timeout when initializing the webservice stub and I'm even logging it using getTimeout() before making the call to make sure it's set but the call completes regardless of the timeout value set. Is it possible this is a bug or am I missing something here?

Below is my code doing this:

proxy = new DCPControllerWSPortTypeProxy();
proxy.setEndpoint(endpoint);            
((Stub)proxy.getDCPControllerWSPortType()).setTimeout(120000);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江南烟雨〆相思醉 2024-12-16 05:14:54

要解决此问题,您必须在项目中的任意位置添加以下类。当我遇到类似的问题时,我已将其声明为与我实例化存根的同一类中的私有类。 (我目前正在使用 Axis 2 )

private class CustomNetworkClient extends sun.net.NetworkClient
{
    
    public CustomNetworkClient(int readTimeout)
    {
        defaultSoTimeout = readTimeout;
        
    }
    
}

完成此操作后,您可以在代码中添加以下行,这将设置超时。

CustomNetworkClient client = new CustomNetworkClient(SOAP_READ_TIMEOUT);

或者您可以简单地执行以下操作,因为您实际上并不需要正在创建的对象:

new CustomNetworkClient(SOAP_READ_TIMEOUT)

这之前已被报告为错误,其中使用 HTTPS 连接时未设置连接超时和读取超时: https://bugs.java.com/bugdatabase/view_bug?bug_id=4700777

以下链接帮助我找到了此解决方法:
http://www.noizeramp.com/article.php?article=se- Networking_Specifics_under_Java_Web_Start

我希望这会对您有所帮助 =)

To fix the problem, you will have to add the following class wherever you want in your project. When I had a similar problem, I have declared it as a private class in the same class where I'm instantiating my stub. (I'm currently using Axis 2 )

private class CustomNetworkClient extends sun.net.NetworkClient
{
    
    public CustomNetworkClient(int readTimeout)
    {
        defaultSoTimeout = readTimeout;
        
    }
    
}

After doing that, you could add the following line in your code, which will set the timeout.

CustomNetworkClient client = new CustomNetworkClient(SOAP_READ_TIMEOUT);

Or you could simply do the following, since you don't really need the object that's being created:

new CustomNetworkClient(SOAP_READ_TIMEOUT)

This has been reported as a bug before, where connection timeouts and read timeouts are not being set when using HTTPS connections : https://bugs.java.com/bugdatabase/view_bug?bug_id=4700777

The following link helped me figure out this workaround:
http://www.noizeramp.com/article.php?article=se-networking_specifics_under_Java_Web_Start

I hope this will help you somehow =)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文