【发布时间】:2015-08-10 06:51:55
【问题描述】:
调用我的 WCF REST 服务时,我收到以下异常 The operation has timed out。
我基本上有一个 WCF Web 服务项目和一个引用已编译 WCF 程序集的网站。 Web 服务很有魅力,所以我的问题不在于我的 web.config 中有不正确的绑定、端点或服务定义。
只有在我尝试插入大量数据时才会出现此问题。
web.config 包含以下信息:
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime enable="true" executionTimeout="100000"
maxRequestLength="2147483647"/>
</system.web>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
receiveTimeout="00:10:00"
sendTimeout="00:10:00">
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
项目(windows 服务)中没有引用我的 WCF Web 服务,因为我使用的是包装器 (sdk),它负责发出所有相关的 http 请求并将对象转换为 json,反之亦然。所有 http 请求都是通过称为 sdk 的 WebClient 发出的。在这种情况下:
byte[] returnBuffer = await client.UploadDataTaskAsync(uriString,
"POST", requestBuffer);
虽然这发生在一个实时站点上(哎呀!!),我可以通过在我的 Web 服务中放置一个断点并让它挂起 90 秒左右来轻松重现该问题,然后如果我尝试继续单步执行,生成特定错误,当它尝试继续运行函数中的剩余代码时,异常会返回给客户端。
我已经用谷歌搜索这个问题几个小时了,但我没有得到任何结果。我的网络服务仍然超时默认的 90 秒。
我想知道的另一件事。我一直在阅读很多不同的文章,提到客户端应用程序,在我的情况下,我的 Windows 服务应该在 app.config 中具有绑定、端点等信息。我没有,到目前为止我也不需要一个。我应该看看这个吗??看起来确实超时发生在 Web 服务而不是客户端上。
有什么想法吗?
谢谢。
更新:
我添加了有关我的 web.config 的附加信息(即服务和行为定义):
<services>
<service name="MyCompany.Web.Services.WebDataService"
behaviorConfiguration="WebDataServiceBehaviour">
<endpoint address="" binding="webHttpBinding"
contract="MyCompany.Web.Services.IWebDataService"
behaviorConfiguration="webBehaviour">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WebDataServiceBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
【问题讨论】:
-
将您的绑定命名为
<binding name="myWebHttpBinding" ...>...</binding>并像这样使用它:
标签: c# web-services wcf wcf-rest