Search code examples
c#soaptimeout

How to set a timeout on a SOAP call in MS .Net 4.5 using C#


I need to account for extremely slow responses from a SOAP server. I have added the service in C# language using Visual Studio 2012 and I really would like to be able to easily set a timeout value on the service object and handle a suitably named exception when a response is not received within that time frame.

How can I implement this?


Solution

  • It's in the documentation: http://msdn.microsoft.com/en-us/library/microsoft.web.services2.soapwebrequest.timeout.aspx .

    In short, use the SoapWebRequest's Timeout property.