Служба WCF 413 независимо от того, какой элемент конфигурации я изменяю

Я пытался понять это в течение нескольких дней, но безрезультатно. Это происходит как при попытке отладки в Visual Studio с использованием IIS Express, так и с использованием моего производственного веб-сайта, развернутого на машине с IIS 7.5.

Я вызвал службу из тестового модуля Visual Studio с помощью HttpWebRequest и в Fiddler 4 такие же ошибки. Поэтому я не думаю, что это конфигурация клиента WCF, так как я не использую ее.

Независимо от того, что я изменяю в моем файле конфигурации, я всегда получаю это исключение:

"Exception thrown: 'System.ServiceModel.ProtocolException' in 
System.ServiceModel.dll

Additional information: The maximum message size quota for incoming messages 
(65536) has been exceeded. To increase the quota, use the 
MaxReceivedMessageSize property on the appropriate binding element."

Прилагаемый ниже файл Web.config предназначен для приложения, которое не находится в корне моего сервера.

Я звоню, используя конечную точку json, используя Ajax.

Я не могу понять, почему я получаю ограничение в 64 КБ, особенно учитывая, что я добавил все элементы в webHttpBinding как ниже.

Я также изменил httpRuntime элемент путем добавления maxRequestLength изменил фильтрацию запросов, настройки безопасности и множество других вещей, которые не имели значения.

Обратите также внимание, что я включил трассировку. .svclog файл не сказал мне больше ничего.

Заранее благодарю за любую помощь.

 <?xml version="1.0"?>
 <configuration>
    <appSettings>
       <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
       <add key="FactoryType" value="Production"/>
       <add key="TravelRequestConnectionString" value="Data Source=ITLCS.benderson.com;Initial Catalog=TestTravelRequestSite;User Id=XXXX;Password=XXXXX"/>
    </appSettings>
    <system.web>
       <compilation debug="true" targetFramework="4.6.1" />
       <httpRuntime targetFramework="4.6.1"/>
       <membership defaultProvider="ADMembershipProvider">
          <providers>
             <clear />
             <add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
          </providers>
       </membership>
    </system.web>
    <system.serviceModel>
       <services>
          <service name="TravelRequestWebService.TravelRequestService">
             <endpoint
                 address="web"
                 binding="basicHttpBinding"
                 contract="TravelRequestWebService.ITravelRequestService" />
             <endpoint
                 address="json"
                 binding="webHttpBinding"
                 behaviorConfiguration="jsonBehavior"
                 contract="TravelRequestWebService.ITravelRequestService" />
             <endpoint
                 address=""
                 binding="basicHttpBinding"
                 contract="TravelRequestWebService.ITravelRequestService" />
          </service>
       </services>
       <behaviors>
          <serviceBehaviors>
             <behavior name="defaultBehavior">
                <!-- 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="true"/>
             </behavior>
             <behavior name="bigBehavior">
                <dataContractSerializer maxItemsInObjectGraph="200"/>
             </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
             <behavior name="WebBehavior">
                <webHttp/>
             </behavior>
             <behavior name="jsonBehavior">
                <enableWebScript/>
             </behavior>
          </endpointBehaviors>
       </behaviors>
       <bindings>
          <webHttpBinding>
             <binding name="webHttpBinding" allowCookies="true"
                      maxReceivedMessageSize="20000000"
                      maxBufferSize="20000000">
             </binding>
          </webHttpBinding>
          <basicHttpBinding>
             <binding name="basicHttpBinding" allowCookies="true"
                      maxReceivedMessageSize="20000000"
                      maxBufferSize="20000000">
             </binding>
          </basicHttpBinding>
       </bindings>
       <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" />
       </protocolMapping>
       <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    </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>
    <system.diagnostics>
       <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true">
             <listeners>
                <add name="xml" />
             </listeners>
          </source>
          <source name="CardSpace">
             <listeners>
                <add name="xml" />
             </listeners>
          </source>
          <source name="System.IO.Log">
             <listeners>
                <add name="xml" />
             </listeners>
          </source>
          <source name="System.Runtime.Serialization">
             <listeners>
                <add name="xml" />
             </listeners>
          </source>
          <source name="System.IdentityModel">
             <listeners>
                <add name="xml" />
             </listeners>
          </source>
       </sources>
       <sharedListeners>
          <add name="xml"
               type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="c:\log\Traces.svclog" />
       </sharedListeners>
    </system.diagnostics>
 </configuration>

1 ответ

Решение

Попробуйте изменить ваш конфиг на это:

  <service name="TravelRequestWebService.TravelRequestService">
     <endpoint
         address="web"
         binding="basicHttpBinding"
         bindingConfiguration="basicHttpBinding"
         contract="TravelRequestWebService.ITravelRequestService" />
     <endpoint
         address="json"
         binding="webHttpBinding"
         behaviorConfiguration="jsonBehavior"
         bindingConfiguration="webHttpBinding"
         contract="TravelRequestWebService.ITravelRequestService" />
     <endpoint
         address=""
         binding="basicHttpBinding"
         contract="TravelRequestWebService.ITravelRequestService" />
  </service>

Подсказкой было ограничение в 64 КБ для размера сообщения в сообщении об ошибке. Это подразумевало, что ваша конфигурация привязки не использовалась WCF. Тот факт, что конфигурации названы так же, как привязки конечной точки, добавил путаницу.

Другие вопросы по тегам