【问题标题】:wcf declarative wf service: web.config settingswcf 声明性 wf 服务:web.config 设置
【发布时间】:2012-07-27 14:46:45
【问题描述】:

技术人员-- 我收到了一条非常流行的消息:“已超出传入消息的最大消息大小配额 (65536)。要增加配额,请在适当的绑定上使用 MaxReceivedMessageSize 属性”。这里没有什么新东西——我需要按照消息中的内容去做。我的麻烦是我不确定在服务 web.config 文件中的哪个位置进行设置。

这是我第一次使用声明式工作流服务,所以请和我一起坚持下去。看起来生成的 web.config 文件比为其他类型的 wcf 服务生成的文件要轻一些。这是开箱即用的默认设置:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
 </behaviors>
 <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
 </system.serviceModel>
 <system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

当我运行 svcutil.exe 来为此生成代理类时,生成的内容如下:

 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
 <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_TelaPointSMService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false"
                hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" 
                maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" 
                 maxArrayLength="16384"
                 maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                  <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                   <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:18781/TelaPointSMService.xamlx"
            binding="basicHttpBinding"
             bindingConfiguration="BasicHttpBinding_TelaPointSMService"
            contract="TelaPointSMService" name="BasicHttpBinding_TelaPointSMService" />
    </client>
   </system.serviceModel>
   </configuration>

那么在工作流服务的 web.config 文件中,我将声明什么/如何声明以确保该服务可以处理大于默认设置的消息?我认识到客户端绑定中的设置也必须更改 - 但在哪里进行更改是明确的。

【问题讨论】:

    标签: wcf web-config wcf-binding


    【解决方案1】:

    看起来您使用的是 4.0,因此由于默认端点和绑定,配置文件会更轻。如您所见,这样做的问题在于默认绑定具有默认设置。

    要解决此问题,您可以在服务的配置文件中显式定义一个默认绑定,该绑定将用于具有该绑定的任何服务。为此,您像往常一样定义绑定,但省略了name 属性,因此您将拥有如下内容:

    <system.serviceModel>     
      <bindings>         
        <basicHttpBinding>             
          <binding maxReceivedMessageSize="5242880" />
        </basicHttpBinding> 
      </bindings>
      <!-- The rest of your services config file -->
    </system.serviceModel>
    

    您可能还需要增加其他值(可能是缓冲区大小),因此您可以像 maxReceivedMessageSize 一样添加它们。值 5242880 是我过去使用的值,但您可能需要更大的值(或者更小的值可能适合您)。

    【讨论】:

    • 蒂姆,非常感谢您为我回答这个问题。我真的很感激!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-16
    • 2012-06-23
    • 1970-01-01
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多