连续的Web服务调用总是超时 [英] Consecutive web service calls always time out

查看:81
本文介绍了连续的Web服务调用总是超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Experts,

Hi Experts,

我有一个服务器应用程序,它提供Web服务来下载一些二进制数据。在客户端侧,我使用由.NET框架从SoapHttpClientProtocol继承做异步调用生成的代理,如下图所示

I have a server application which provides web service to download some binary data. At the client side, I use the proxy generated by .net framework which inherits from SoapHttpClientProtocol to do async call, shown as below

公共部分类服务:System.Web.Services.Protocols。 SoapHttpClientProtocol {

public partial class service : System.Web.Services.Protocols.SoapHttpClientProtocol {

...

公共System.IAsyncResult BeginRetrieveData(PrintQueueWebServiceRetrieveDataRequest PrintQueueWebServiceRetrieveDataRequest,System.AsyncCallback回调,对象asyncState)

        {

           返回this.BeginInvoke(QUOT; RetrieveData" ;,新的对象[] {

             &NBSP ;      PrintQueueWebServiceRetrieveDataRequest},回调,asyncState);

        }

public System.IAsyncResult BeginRetrieveData(PrintQueueWebServiceRetrieveDataRequest PrintQueueWebServiceRetrieveDataRequest, System.AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("RetrieveData", new object[] {
                    PrintQueueWebServiceRetrieveDataRequest}, callback, asyncState);
        }

...

}

service myService = new Service();

service myService = new Service();

的IAsyncResult asyncResult =为myService .BeginRetrieveData(请求,NULL,NULL);

WaitHandle.WaitAny(新的WaitHandle [] {asyncResult.AsyncWaitHandle,terminate.handle},为myService .Timeout ,false);

IAsyncResult asyncResult = myService .BeginRetrieveData(request, null, null);
WaitHandle.WaitAny(new WaitHandle[] { asyncResult.AsyncWaitHandle, terminate.handle }, myService .Timeout, false);

if(!asyncResult.AsyncWaitHandle.WaitOne(0,false))

{

if (!asyncResult.AsyncWaitHandle.WaitOne(0, false))
{

/ /如果超时,请尝试再次拨打电话

//Try to call again in case of time out

}

如果超时,我想再次拨打网络服务电话对较小的二进制数据块的请求(当然它是由服务支持的)。但是,无论chunck有多小,连续的呼叫总是会超时。我试图
首先调用myService.Abort()或myService.CancelAsync(),甚至使用服务代理的新实例,它们都不起作用。

In case of time out, I'd like to call the web service again with a request to a smaller chunk of the binary data (of course it's supported by the service). However, no matter how small the chunck is, the consecutive calls would always time out. I tried to call myService.Abort() or myService.CancelAsync() first or even use a new instance of service proxy, none of them works.

我怎样才能实现这个??在此先感谢您的帮助!

How can I achieve this?? Thanks in advance for your help!!

推荐答案

由于Timeout是一个例外,您可以将代码包含在try catch机制中,并且在catch块你可以用少量的数据重试你的请求。

As Timeout is an exception you can enclose your code inside a try catch mechanism and in the catch block you can retry your request with a lesser amount of chunck of data.


这篇关于连续的Web服务调用总是超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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