C#調用WebService服務時,報錯,The operation has timed out,意思是“操作超時”。

方法/步驟
-
首先修改服務端配置
WebService服務所在站點為服務端,它提供了服務,打開這個站點的web.config,添加下面的配置:
<httpRuntime executionTimeout="300000" />
<compilation defaultLanguage="c#" debug="false">
executionTimeout="300000" 單位是“毫秒”,這里配置的是5分鍾。
debug="false" 要關閉調試。
如果web.config中本來就有這兩個配置,修改一下就行了。如果沒有,就添加上去,完整的結構順序如下:
<configuration>
<system.web>
<httpRuntime executionTimeout="300000" />
<compilation defaultLanguage="c#" debug="false">
</compilation>
</system.web>
</configuration>
-
修改調用程序客戶端的配置
YourService. YourService model = new YourService. YourService ();
model.Timeout = 300000; // 單位是毫秒,設置時間,否則時間超限
這里給服務對象model設置超時時間Timeout為300000毫秒。