在调用webservice出现超时问题的,可以尝试如下的方法来解决。
一、
1、web.config配置,<system.web></system.web>里面增加:
<httpRuntime maxRequestLength="10240" appRequestQueueLimit="100" useFullyQualifiedRedirectUrl="true" executionTimeout="1200" />
2、扩大代理类的超时限制,默认是90秒
YourWebService yws = new YourWebService();
yws.Timeout = 1200000; //20分钟
yws.Timeout = 1200000; //20分钟
3、IIS属性-网站 连接超时时间 1200秒
二、
1、修改 app.config 文件,添加如下代码:
<httpRuntime executionTimeout="600" />
2、设置 Web services 的 Timeout 属性
对 XML Web services 的同步调用的超时(以毫秒为单位)。默认为 100000 毫秒。
lywSqCommon.sqsdData.GetData getData = new lywSqCommon.sqsdData.GetData();//GetData 为类名
getData.Timeout=700000;//单位为毫秒
getData.Timeout=700000;//单位为毫秒
指示 XML Web services 客户端等待同步 XML Web services 请求完成的时间(以毫秒计)。
提示:如果将 Timeout 属性设置为 Timeout.Infinite,则指示该请求无超时。即使 XML Web services 客户端可以将 Timeout 属性设置为无超时,Web 服务器仍可以在服务器端使请求超时。
系统将以上面两项设置的最小者作为操作超时的时间长度。
记得要把 web.config 的 debug 模式关闭:
< compilation
defaultLanguage="c#"
debug="false"
/>
如果 debug 模式没有关闭, executionTimeout 会被忽略. 这时候, 如果应用是在单步跟踪的模式下, 根据经验, 超时时间大约是 90 秒(在 machine.config 里设置的, 我猜的^_^), 如果不是在单步跟踪的模式下, 超时时间可能是 20 分钟(也是我猜的, 因为其 session 的缺省超时时间是 20 分钟, 哈). 我懒得找微软的文档作进一步的求证了, 反正我用不着知道 debug 模式下的确切超时时间.
收藏本站 设为主页

