简体   繁体   English

C#Web参考-在app.config中设置超时

[英]C# web reference -setting the Timeout in app.config

I have a program that uses web reference in order to connect to the server. 我有一个程序使用Web参考来连接到服务器。 The web reference is configured in app.config file in the following way: Web参考是通过以下方式在app.config文件中配置的:

   <applicationSettings>
        <blala.Properties.Settings>
          <setting name="blablaClient_AppexScan_Service1" serializeAs="String">
            <value>http://www.apex.com/CxWS/Service1.asmx</value>
          </setting>
        </blabla.Properties.Settings>
  <applicationSettings>

I would like to add to the setting a property of Timeout. 我想在设置中添加超时属性。 I would like to change the default timeout from 100000 msec to something else and I would like to do it in the app.config. 我想将默认超时时间从100000毫秒更改为其他方式,我想在app.config中进行操作。

when I tried to add: 当我尝试添加时:

<setting name="Timeout" serializeAs="String">

       <value>30</value>

</setting>

it didn't change the default timeout. 它没有更改默认超时。 How can I do it? 我该怎么做?

Adjust the proxy of your web service 调整您的Web服务的代理

var timeout = System.Configuration.ConfigurationSettings.AppSettings["Timeout"];

WebReference.ProxyClass myProxy = new WebReference.ProxyClass();
myProxy.Timeout = timeout; 

Try to set the timeout after initialising your web services. 初始化Web服务后,尝试设置超时。

WSName.WSClass refWS = WSMng.Initialize(ServerName, ServerPort, ServerInstance, ServerCompanyName);
refWS.Timeout = 200000;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM