控制台应用程序 (.NET) 中的 SOAP 请求超时
-
19-08-2019 - |
题
我将 SOAP Web 服务添加到控制台应用程序中,每次我进行特定调用时都会超时。其他电话工作正常。如何增加控制台应用程序中的超时长度?目前好像是90秒左右。
谢谢。
解决方案
您可以通过设置 Web 服务客户端超时 暂停 财产。默认值为 100000 毫秒(100 秒)。
例如:
MyWebServices.Webservice svc = new MyWebServices.Webservice();
// Set timeout to 200 seconds
svc.Timeout = 200000;
svc.DoWork();
其他提示
这应该允许您更改超时,然后验证它已被更改。
公众诠释超时{得到;组; }
[交易(超时= 30)] 公共类TransactionAttribute_Timeout:ServicedComponent的 { 公共无效TimeoutExample() { //获取TransactionAttribute应用于类。 TransactionAttribute属性= (TransactionAttribute)Attribute.GetCustomAttribute( this.GetType() typeof运算(TransactionAttribute), 假);
// Display the current value of the attribute's Timeout property.
Console.WriteLine("TransactionAttribute.Timeout: {0}",
attribute.Timeout);
// Set the Timeout property value of the attribute to sixty
// seconds.
attribute.Timeout = 60;
// Display the new value of the attribute's Timeout property.
Console.WriteLine("TransactionAttribute.Timeout: {0}",
attribute.Timeout);
}
}
不隶属于 StackOverflow