views:

561

answers:

2

I have a SOAP web service added to a console app and every time I make a specific call its timing out on me. Other calls work fine. How do I increase the timeout length in a console app? Seems like it's currently about 90 seconds.

Thanks.

A: 

This should allow you to change the timeout and then verify that it has been changed.

public int Timeout { get; set; }

[Transaction(Timeout=30)] public class TransactionAttribute_Timeout : ServicedComponent { public void TimeoutExample() { // Get the TransactionAttribute applied to the class. TransactionAttribute attribute = (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);
}

}

Shaun Humphries
+1  A: 

You can set the web service client timeout by setting the Timeout property. The default is 100000 milliseconds (100 seconds).

For example:

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

HTH
Kev

Kev