Я не могу изменить максимальный размер квоты для входящего сообщения, Служба WCF - PullRequest
0 голосов
/ 31 августа 2018
**Web Config:**
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <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>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <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>
    <!--Add refernce to any new service that is to be added
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true">
      <serviceActivations>
        <add relativeAddress="EmployeeService.svc" service="PeopleInbox.ServiceLibrary.EmployeeService" />
        <add relativeAddress="LookupService.svc" service="PeopleInbox.ServiceLibrary.LookupService" />
        <add relativeAddress="SecurityService.svc" service="PeopleInbox.ServiceLibrary.SecurityService" />
        <add relativeAddress="EmployerService.svc" service="PeopleInbox.ServiceLibrary.EmployerService" />
      </serviceActivations>
    </serviceHostingEnvironment>-->
    <services>
      <service name="PeopleInbox.ServiceLibrary.EmployeeService">
        <endpoint address="" binding="basicHttpBinding" contract="PeopleInbox.ServiceLibrary.IEmployeeService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/PeopleInbox.ServiceLibrary/EmployeeService/" />
          </baseAddresses>
        </host>
      </service>

      <service name="PeopleInbox.ServiceLibrary.AdminService">
        <endpoint address="" binding="basicHttpBinding" contract="PeopleInbox.ServiceLibrary.IAdminService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/PeopleInbox.ServiceLibrary/AdminService/" />
          </baseAddresses>
        </host>
      </service>

      <service name="PeopleInbox.ServiceLibrary.LookupService">
        <endpoint address="" binding="basicHttpBinding" contract="PeopleInbox.ServiceLibrary.ILookupService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/PeopleInbox.ServiceLibrary/LookupService/" />
          </baseAddresses>
        </host>
      </service>
      <service name="PeopleInbox.ServiceLibrary.SecurityService">
        <endpoint address="" binding="basicHttpBinding" contract="PeopleInbox.ServiceLibrary.ISecurityService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/PeopleInbox.ServiceLibrary/SecurityService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </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>

  <runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>

        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />

      </dependentAssembly>

    </assemblyBinding>

  </runtime>
</configuration>

Error Превышен максимальный размер квоты для входящих сообщений (65536). Чтобы увеличить квоту, используйте свойство MaxReceivedMessageSize для соответствующего элемента привязки.

Скажите, пожалуйста, где установить maxReceivedMessageSize. Я не могу создать привязку и не знаю, как использовать. Я проверяю много учебника, но не могу найти правильный ответ, который делает код работающим. Спасибо

1 Ответ

0 голосов
/ 31 августа 2018

Необходимо создать конфигурацию привязки и назначить ее атрибуту bindingConfiguration в службе (ах).

Чтобы создать привязку, вы добавляете раздел в разделе <system.serviceModel> файла конфигурации, например:

<bindings>
  <basicHttpBinding>
    <binding name="MyHttpBinding" 
             maxReceivedMessageSize="2147483647" />
  </basicHttpBinding>
</bindings>

Затем в конечных точках службы вы назначаете вышеуказанную привязку через атрибут bindingConfiguration элемента <endpoint>. Например:

<endpoint address="" binding="basicHttpBinding" 
          bindingConfiguration="MyHttpBinding"
          contract="PeopleInbox.ServiceLibrary.IAdminService">

Это приведет к тому, что определенная конечная точка будет использовать заданную вами привязку (для значения maxReceivedMessageSize которого установлено максимальное значение атрибута (Int32.MaxValue) вместо значения по умолчанию 65536 для basicHttpBinding.

...