SOAP request timeout in console application (.NET)

I have a SOAP web service added to a console application, and every time I make a specific call, its time is on me. Other calls work fine. How to increase the timeout length in a console application? It seems like about 90 seconds now.

Thanks.

+3
source share
2 answers

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

For example:

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

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

public int Timeout {get; set; }

[ ( = 30)] TransactionAttribute_Timeout: ServicedComponent {   public void TimeoutExample()   {       // TransactionAttribute, .        TransactionAttribute =           (TransactionAttribute) Attribute.GetCustomAttribute(           this.GetType(),           TypeOf (TransactionAttribute),           );

    // Display the current value of the attribute 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 Timeout property.
    Console.WriteLine("TransactionAttribute.Timeout: {0}",
        attribute.Timeout);
}

}

0

Source: https://habr.com/ru/post/1704887/


All Articles