发生 WebClientProtocol 超时时会发生什么
我们有一个引用 Web 服务的客户端应用程序。 我们已将 webclientprotocol 对象的超时属性设置为 50(毫秒),并希望观察发生了什么。 我们绑定了一个长时间运行的 Web 方法,该方法向客户端返回一个巨大的数据集。 当默认值存在时,DataSet 会正确返回给客户端。 当我们将其更改为 50(ms) 时,我们没有观察到任何情况。 我们的假设是,由于发生超时,客户端会发生某种异常。 谁能解释一下这里发生了什么
谢谢 拉杰
We have a client application that has reference to a webservice. We had set the timeout property on the webclientprotocol object to 50 (ms) and wanted to observe what goes on. We tied up a long running webmethod that returns a huge DataSet to the client. When the default value was there, the DataSet was returned properly to the client. When we changed this to 50(ms), we did not observe anything. Our assumption was that there would be some kind of exception that occurs on the client side since the timeout has occurred. Can anyone please explain what is going on here
Thanks
Raj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,该文档不清楚。 当你说“没有观察到任何东西”时,你到底是什么意思? 代码会永远挂起吗? 是否抛出异常? 推测未返回有效的数据集。
我期望一个TimeoutException被抛出,但令我惊讶的是,这在您的客户端代码中并不完全明显。 你没有接受例外,是吗?
您是同步执行调用还是异步执行调用? 如果它是异步的,我希望执行回调,然后在“EndXxx”调用上抛出异常。
我强烈建议您编写一个简短的控制台应用程序,它只是调用 Web 服务,只是为了看看会发生什么。
The documentation is unfortunately unclear. When you say you "didn't observe anything" what exactly do you mean? Did the code hang forever? Was an exception thrown? Presumaby a valid DataSet wasn't returned.
I would expect a TimeoutException to be thrown but I'm surprised that wasn't entirely obvious in your client code. You're not swallowing exceptions, are you?
Are you executing the call synchronously or asynchronously? If it's asynchronous, I'd expect the callback to be executed and then the exception to be thrown on the "EndXxx" call.
I strongly recommend that you write a short console application which just calls the web service, just to see what happens.
我刚刚遇到了这个。 在 .NET 2.0 Web 服务中,它会抛出一个非常不具体的
WebException
,只有Message
属性来区分它:我还没有在较新版本的 Visual Studio 中默认生成的基于 WCF 的服务引用中尝试过它,但如果我理解 this 正确的话,它们会抛出一个更有用的
TimeoutException
,就像 Jon Skeet,我猜测(并且更愿意)是 Web 服务中的行为。请注意,超时仅适用于同步调用(至少在 Web 服务中;我认为对于 WCF 服务引用也是如此)。 如果您希望异步调用超时,则必须设置计时器并手动中止调用,如演示的 此处。
I just ran into this. In a .NET 2.0 Web service, it throws a pretty unspecific
WebException
, with only theMessage
property to distinguish it:I haven't tried it in the WCF-based service references generated by default in newer versions of Visual Studio, but if I understand this correctly, they throw a more useful
TimeoutException
, which, like Jon Skeet, I would have guessed (and would prefer) to be the behavior in a Web service.Note that the timeout is only for synchronous calls (at least in a Web service; I think it's true for a WCF service reference, too). If you want an asynchronous call to time out, you'll have to set a timer and abort the call manually, such as demonstrated here.