3

我在控制台应用程序中添加了一个 SOAP Web 服务,每次我进行特定调用时,它都会超时。其他电话工作正常。如何增加控制台应用程序中的超时长度?似乎目前大约是 90 秒。

谢谢。

4

2 回答 2

5

您可以通过设置Timeout属性来设置 Web 服务客户端超时。默认值为 100000 毫秒(100 秒)。

例如:

MyWebServices.Webservice svc = new MyWebServices.Webservice();
// Set timeout to 200 seconds
svc.Timeout = 200000;
svc.DoWork();
于 2009-03-17T12:32:18.803 回答
0

这应该允许您更改超时,然后验证它是否已更改。

公共 int 超时 { 获取;放; }

[Transaction(Timeout=30)] public class TransactionAttribute_Timeout : ServicedComponent { public void TimeoutExample() { // 获取应用到类的 TransactionAttribute。TransactionAttribute 属性 = (TransactionAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(TransactionAttribute), false);

    // 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);
}

}

于 2009-03-17T12:31:53.253 回答