简体   繁体   English

如何为WCF Web角色配置消息大小(当前获得HTTP错误代码500)

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

Thank you all! 谢谢你们!

We were able to solve this problem simply by changing the binding element name from "basicHttpBinding" to "webHttpBinding". 通过将绑定元素名称从“ basicHttpBinding”更改为“ webHttpBinding”,我们能够解决此问题。

Silly, I know.. 傻,我知道..


Hello, 你好,

I am trying to implement a web role using WCF, that will receive JSON objects and store them in the Azure storage. 我正在尝试使用WCF实施Web角色,该角色将接收JSON对象并将其存储在Azure存储中。 During the integration tests I got a 400 error code. 在集成测试中,我得到了400错误代码。 I then discovered that WCF has a very small message size (~65535), and that I need to configure it to be larger. 然后,我发现WCF的消息大小非常小(〜65535),我需要将其配置为更大。 The configuration I am currently using causes a 500 error code whenever I try to post an HTTP request to my service (the request never reaches my code). 每当我尝试将HTTP请求发布到服务时,我当前使用的配置都会导致500错误代码(该请求永远不会到达我的代码)。

The Web.config file I am using looks like this: 我正在使用的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>

Can you please help me get my requests through to my WCF service? 您能帮我将请求发送到WCF服务吗?

Thanks! 谢谢!

Have you tried increasing the message receive size on your binding? 您是否尝试过增加绑定上的邮件接收大小? Such as... 如...

maxReceivedMessageSize="1048576" maxReceivedMessageSize =“ 1048576”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM