Wednesday, March 7, 2012

How to set time out for service request in WCF

Time adjustments can categorizes in two scenarios.
1. Receiving Time settings at Application Side
2. Sending Time settings from Application

 To set data receiving timing at application we will have to make changes in the file named ServiceReferences.ClientConfig located at the root of the client application.

First Locate the binding of the service you want to increase timing of , under the basicHttpBinding tag. Now add the following code in the Binding Tag

openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"

 Now this will increase the time upto 10 mints for receiving and sending requests.

 your code will look some thing like that

<binding name="YourServiceName" closeTimeout="00:10:00"
 openTimeout="00:10:00" receiveTimeout="00:10:00" 
 sendTimeout="00:10:00"
 maxBufferSize="2147483647" 
 maxReceivedMessageSize="2147483647">
<security mode="None" />
Now to set that timing for server one should have to make changes to the servers Web.config File located at the root of the server application.

<bindings>
  <basicHttpBinding>
    <binding name=""  
  openTimeout="00:10:00" 
  receiveTimeout="00:10:00" 
  sendTimeout="00:10:00"
     </binding>
   </basicHttpBinding>
 </bindings>

This code will set the send and receive timing for all services to 10 min.

No comments:

Post a Comment