RESTful 服务中 webHttpBinding 的绑定和配置?
我是 WCF 的新手,正在尝试了解服务所采用的迷宫般的配置。我有一个休息服务,可以返回表的导出,该表大于默认的 maxReceivedMessageSize 。因此,我一直在尝试使用此服务/端点的配置,但一无所获。下面是我正在做的事情的要点,我错过了什么?我只是以 JSON 或 XML 形式返回 List,并且需要能够返回超过默认阈值的值。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<!-- defin service -->
<service behaviorConfiguration="EPRestBehavior" name="EPRestDNS">
<endpoint address=""
bindingConfiguration="ApiExportBinding"
binding="webHttpBinding"
contract="IDNSRestService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="EPRestBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
...
</behaviors>
<bindings>
<!-- Customizations for REST service -->
<webHttpBinding>
<binding name="ApiExportBinding" maxReceivedMessageSize="10485760"
maxBufferPoolSize="10485760" maxBufferSize="10485760" closeTimeout="00:03:00"
openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
<readerQuotas maxDepth="32" maxStringContentLength="10485760"
maxArrayLength="10485760" maxBytesPerRead="10485760" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
更新1 我已经删除了所有这些配置,并尝试使用现有的 webHttpEndpoint 部分进行一些简单的操作:
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="1000000000" />
</webHttpEndpoint>
</standardEndpoints>
具有相同的结果。 HTTP/1.1 502 连接被对等方重置
I'm new to WCF and am trying to get my head around the labyrinth of configurations the services take. I have a rest service that can return an export of a table, which it larger than the default maxReceivedMessageSize
. So I'm been trying to play with the config for this service/endpoint and I'm getting nowhere. Below if the gist of what I'm working on, what am I missing? I simply return List as either JSON or XML and I need to be able to return over the default threshold.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<!-- defin service -->
<service behaviorConfiguration="EPRestBehavior" name="EPRestDNS">
<endpoint address=""
bindingConfiguration="ApiExportBinding"
binding="webHttpBinding"
contract="IDNSRestService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="EPRestBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
...
</behaviors>
<bindings>
<!-- Customizations for REST service -->
<webHttpBinding>
<binding name="ApiExportBinding" maxReceivedMessageSize="10485760"
maxBufferPoolSize="10485760" maxBufferSize="10485760" closeTimeout="00:03:00"
openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
<readerQuotas maxDepth="32" maxStringContentLength="10485760"
maxArrayLength="10485760" maxBytesPerRead="10485760" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
UPDATE 1
I've removed all of that config and tried something simper with the existing webHttpEndpoint section:
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="1000000000" />
</webHttpEndpoint>
</standardEndpoints>
with the same results. HTTP/1.1 502 Connection reset by peer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是 WCF 可怕的原因。最后,我在服务器上创建了一个 svclog,实际问题是达到了默认对象图中的限制。我在实施中添加了我想要的新限制,就是这样。 7个多小时就为了这种愚蠢的事情。
All this is why WCF is horrible. In the end I create a svclog on the server and the actual issue was hitting the limit in the default object graph. I added the new limit I want to the implementation, and that was that. 7+ hours just for a stupid thing like that.
异常是发生在服务端还是客户端?一个常见的错误是您更改了服务器上的值,但忘记也在客户端上进行更改。
Does the exception occur on the service or the client side? A common mistake is that you change the values on the server but forget to change also on the client.