簡體   English   中英

如何為WCF Web角色配置消息大小(當前獲得HTTP錯誤代碼500)

[英]How to configure the message size for a WCF web role (Currently getting HTTP error code 500)

謝謝你們!

通過將綁定元素名稱從“ basicHttpBinding”更改為“ webHttpBinding”,我們能夠解決此問題。

傻,我知道..


你好,

我正在嘗試使用WCF實施Web角色,該角色將接收JSON對象並將其存儲在Azure存儲中。 在集成測試中,我得到了400錯誤代碼。 然后,我發現WCF的消息大小非常小(〜65535),我需要將其配置為更大。 每當我嘗試將HTTP請求發布到服務時,我當前使用的配置都會導致500錯誤代碼(該請求永遠不會到達我的代碼)。

我正在使用的Web.config文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>

  <system.web>

    <compilation debug="true" targetFramework="4.0" />

  </system.web>

  <system.serviceModel> 

    <diagnostics>

      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxSizeOfMessageToLog="5000000" />

      <endToEndTracing activityTracing="false" />

    </diagnostics>

    <services>

      <service name="MyWebRole.RequestHandler" behaviorConfiguration="RequestHandlerbehavior">

        <endpoint address="http://localhost:9001/" binding="basicHttpBinding" bindingConfiguration="conf" name="MyDefaultEndpoint"

                                contract="MyWebRole.IRequestHandler" />

      </service>

    </services>   

    <bindings>

      <basicHttpBinding>

        <binding name="conf" maxBufferSize="5000000" maxReceivedMessageSize="5000000" useDefaultWebProxy="true">

          <readerQuotas maxDepth="5000000" maxStringContentLength="5000000" maxArrayLength="5000000" maxBytesPerRead="5000000" maxNameTableCharCount="5000000" />

        </binding>

      </basicHttpBinding>

    </bindings>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    <behaviors>

      <serviceBehaviors>

        <behavior name="RequestHandlerbehavior">

          <serviceMetadata httpGetEnabled="true" />

          <serviceDebug includeExceptionDetailInFaults="true" />

        </behavior>

      </serviceBehaviors>

    </behaviors>

  </system.serviceModel>

  <system.webServer>

    <modules runAllManagedModulesForAllRequests="true" />

  </system.webServer>

</configuration>

您能幫我將請求發送到WCF服務嗎?

謝謝!

您是否嘗試過增加綁定上的郵件接收大小? 如...

maxReceivedMessageSize =“ 1048576”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM