【问题标题】:WCF Service Increase maximum message size quota and configurationWCF 服务增加最大消息大小配额和配置
【发布时间】:2020-10-06 23:10:13
【问题描述】:

这是我的 WCF 服务的 web.config:

    <configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

    <bindings>
      <wsHttpBinding>
        <binding name="wsBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"  >
          <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.8.6.0" newVersion="1.8.6.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
      <remove invariant="System.Data.SQLite" />
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
    </DbProviderFactories>
  </system.data>
  <connectionStrings>
    <add name="DBContext" connectionString="data source=.\APPDb.sqlite" providerName="System.Data.SQLite" />
    <!--<add name="StardocsVisionContext" connectionString="data source=C:\Program Files (x86)\Stardocs\StardocsVision\Data\StardocsVisionDb.sqlite" providerName="System.Data.SQLite" />-->
  </connectionStrings>
</configuration>

我已阅读此处Wcf-The maximum message size quota for incoming messages (65536) has been exceeded? 的说明以增加最大邮件大小配额。但是,这仅适用于一项服务吗?

如果我有多项服务会怎样?

另外,我似乎必须为我的服务定义基址。但是,当我编译和安装这个应用程序时,基地址是什么?如何更改?

编辑:

我在 web.config 中添加了一个绑定,但我仍然遇到内存问题。

【问题讨论】:

  • 您在wsBinding 中输入一次,然后您可以使用bindingConfiguration="wsBinding" 在多个服务(显然在同一个项目中)中重复使用它
  • 对不起,你能把它放在我的配置里吗?我是 wcf 的新手,我真的很困惑如何做到这一点。
  • 相对部分What happens if I have multiple services?看看这里告诉我:docs.microsoft.com/en-us/dotnet/framework/wcf/…
  • 我更新了我的 web.config 但我仍然遇到同样的问题。

标签: c# .net wcf


【解决方案1】:

如果你有多个服务,你只需要为每个端点应用这个配置,如下:

<protocolMapping>  
    <add binding="wsHttpBinding" scheme="https" bindingConfiguration="wsBinding"/>
</protocolMapping> 

另外,你的绑定配置使用了WSHttpBinding,但是你的端点使用了基本的httpsbinding。你需要将它们的值设置为相同的值。

你的基地址是部署在IIS上设置的地址。

【讨论】:

  • 您好!谢谢回答。这是给客户端的吧?我可以在 wcf 测试客户端中设置它。还是服务器用的?
  • 这是服务器的配置。我建议你研究一下WCF文档,你会有所收获的。docs.microsoft.com/en-us/dotnet/framework/wcf/…
猜你喜欢
  • 2015-04-02
  • 2010-12-15
  • 2015-02-03
  • 2014-06-24
  • 1970-01-01
  • 2014-02-01
  • 2014-10-23
  • 1970-01-01
  • 2012-01-13
相关资源
最近更新 更多