简体   繁体   English

RESTful服务中webHttpBinding的绑定和配置?

[英]binding and configuration for webHttpBinding in RESTful service?

I'm new to WCF and am trying to get my head around the labyrinth of configurations the services take. 我是WCF的新手,正设法使我迷惑于服务所采用的配置迷宫。 I have a rest service that can return an export of a table, which it larger than the default maxReceivedMessageSize . 我有一个rest服务,可以返回表的导出,该表比默认的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. 我只是将List返回为JSON或XML,并且我需要能够返回默认阈值。

<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: 更新1我已经删除了所有配置,并尝试使用现有的webHttpEndpoint部分进行简化操作:

<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="1000000000" />
  </webHttpEndpoint>
</standardEndpoints>

with the same results. 具有相同的结果。 HTTP/1.1 502 Connection reset by peer

All this is why WCF is horrible. 这就是为什么WCF可怕的原因。 In the end I create a svclog on the server and the actual issue was hitting the limit in the default object graph. 最后,我在服务器上创建了一个svclog,实际问题是达到默认对象图中的限制。 I added the new limit I want to the implementation, and that was that. 我在实现中添加了我想要的新限制,仅此而已。 7+ hours just for a stupid thing like that. 像这样愚蠢的事情需要7个多小时。

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, MaxItemsInObjectGraph = 2147483646)]

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. 一个常见的错误是您更改了服务器上的值,却忘记了也更改了客户端上的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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