调用webservice第一次正常,以后就报异常: Request timed out

我在本地的winform中调用部署在另一台机器上的一个webservice,第一次调用时正常,但从第二次开始就产出异常,如下:

Server Error in '/' Application.

Request timed out.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Request timed out.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[HttpException (0x80004005): Request timed out.]

我在网上查了下,发现很多的说法,如

在web.config中加入

<webServices>
            <protocols>
                <add name="HttpSoap"/>
                <add name="HttpPost"/>
                <add name="HttpGet"/>
                <add name="Documentation"/>
            </protocols>
        </webServices>

1.iis->[网站]->属性-》连接超时。默认为120秒
2.web.config 手工添加httpruntime,如
<system.web>
 <httpruntime  executiontimeout="2000" />
</system.web>
3.同步执行webservice时,设置timeout属性

windows应用程序所参照的webservice的Reference.cs文件中,添加下列代码   

using   System.Net;  
protected override WebRequest GetWebRequest(Uri uri)
{
 HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);  
 webRequest.KeepAlive = false;  
 webRequest.ProtocolVersion = HttpVersion.Version10;  
 return webRequest; 
}


以上方法都试过了,但还是产生上述异常。

请高手指教。 


 


凤凰求蛊
浏览 664回答 9
9回答

MMTTMM

用时超过一分钟?那不timeout才怪 1.检查你的服务器端是否出现什么异常 2.如果用了数据库,检查下数据库是否异常

汪汪一只猫

能把你的WebService地址贴出来嘛?

MYYA

你的web service完成什么功能?

炎炎设计

连接超时了

慕容3067478

直接在浏览器访问ws试试

翻过高山走不出你

应该是连接数据库的问题。

慕桂英3389331

部署到远程服务器上试试!

天涯尽头无女友

WF调用,改app.config 下的 receiveTimeout="02:01:00" sendTimeout="02:01:00" <bindings>            <basicHttpBinding>                <binding name="ServiceSoap" closeTimeout="02:01:00" openTimeout="02:01:00"                    receiveTimeout="02:01:00" sendTimeout="02:01:00" allowCookies="false"                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"                    useDefaultWebProxy="true">                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />                    <security mode="None">                        <transport clientCredentialType="None" proxyCredentialType="None"                            realm="" />                        <message clientCredentialType="UserName" algorithmSuite="Default" />                    </security>                </binding>            </basicHttpBinding>        </bindings>

临摹微笑

连接的释放问题?
打开App,查看更多内容
随时随地看视频慕课网APP