控制台应用程序(.NET)中的SOAP请求超时

时间:2009-03-17 12:13:03

标签: .net soap request-timed-out

我在控制台应用程序中添加了一个SOAP Web服务,每次我拨打一个特定的电话时,它都会暂停给我。其他电话工作正常。如何在控制台应用程序中增加超时长度?好像现在大约90秒。

感谢。

2 个答案:

答案 0 :(得分:5)

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

例如:

MyWebServices.Webservice svc = new MyWebServices.Webservice();
// Set timeout to 200 seconds
svc.Timeout = 200000;
svc.DoWork();

答案 1 :(得分:0)

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

public int Timeout {get;组; }

[交易(超时= 30)] public class TransactionAttribute_Timeout:ServicedComponent {     public void 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);
}

}

相关问题