Wes P
Wes P

Reputation: 9870

SOAP Request Timeout in Console App (.NET)

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.

Upvotes: 3

Views: 8178

Answers (2)

Shaun Humphries
Shaun Humphries

Reputation: 1035

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

Upvotes: 0

Kev
Kev

Reputation: 119846

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();

Upvotes: 5

Related Questions