简体   繁体   中英

The operation has timed out in WCF REST Service

I have created a web service using WCF REST Service Template 40(CS) . When I try to consume it using

  var request = WebRequest.Create(string.Concat(serviceUrl, resourceUrl)) as HttpWebRequest;
   if (method == "POST" && requestBody != null)
            {
                byte[] requestBodyBytes = ToByteArrayUsingJsonContractSer(requestBody);
                request.ContentLength = requestBodyBytes.Length;
                using (Stream postStream = request.GetRequestStream())
                    postStream.Write(requestBodyBytes, 0, requestBodyBytes.Length);

            }

var response = request.GetResponse() as HttpWebResponse;

I keep getting:

The operation has timed out

How to increase time out ? Do I need to increase it in service or the client which is using this service with url:

http://myservice.com/RecordingCompleted/

Please suggest

在致电Web服务之前,请尝试此代码。

request.Timeout = 5000;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM