【问题标题】:Sending large XML from Silverlight to WCF将大型 XML 从 Silverlight 发送到 WCF
【发布时间】:2011-02-22 08:56:19
【问题描述】:

我想从 Silverlight 向 WCF SVC 服务发送一个大的 XML 字符串。

看起来任何低于 50k 的东西都可以正确发送,但如果我尝试发送超过该限制的东西,我的请求会到达服务器(调用 BeginRequest)但永远不会到达我的 SVC。我得到了经典的“NotFound”异常。

知道如何提高这个限制吗?

如果我不能提高它?我还有哪些其他选择?

这是我的绑定配置

<bindings>
        <customBinding>
            <binding name="customBinding0" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
                <binaryMessageEncoding>
        <readerQuotas
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxDepth="2147483647"
            maxNameTableCharCount="2147483647"
            maxStringContentLength="2147483647" />

      </binaryMessageEncoding>
                <httpTransport/>
            </binding>
            <binding name="customBindingSecure" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
                <binaryMessageEncoding>
        <readerQuotas
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxDepth="2147483647"
            maxNameTableCharCount="2147483647"
            maxStringContentLength="2147483647" />
                </binaryMessageEncoding>
                <httpsTransport/>
            </binding>
        </customBinding>
    </bindings>

编辑:更多细节:如果我中断 Global.asax Endrequest,我会在响应“Bad Request 400”中看到

编辑:再次详细信息:我激活了跟踪,我可以看到以下错误:已超出传入消息的最大消息大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。

但是,我的 maxReceivedMessageProperty 已经设置为 2147483647。

【问题讨论】:

    标签: .net wcf silverlight


    【解决方案1】:

    好的,成功了!

    由于我使用的是 customBinding,因此必须在 httpTransport 元素上设置 maxReceivedMessageSize,如下所示:

    <bindings>
            <customBinding>
                <binding name="customBinding0" >
                    <binaryMessageEncoding>
            <readerQuotas
                maxArrayLength="2147483647"
                maxBytesPerRead="2147483647"
                maxDepth="2147483647"
                maxNameTableCharCount="2147483647"
                maxStringContentLength="2147483647" />
    
          </binaryMessageEncoding>
                    <httpTransport maxReceivedMessageSize="4194304" />
                </binding>
                <binding name="customBindingSecure">
                    <binaryMessageEncoding>
            <readerQuotas
                maxArrayLength="2147483647"
                maxBytesPerRead="2147483647"
                maxDepth="2147483647"
                maxNameTableCharCount="2147483647"
                maxStringContentLength="2147483647" />
                    </binaryMessageEncoding>
                    <httpsTransport  maxReceivedMessageSize="4194304" />
                </binding>
            </customBinding>
        </bindings>
    

    感谢大家的帮助!

    【讨论】:

      【解决方案2】:

      您还可以打开 WCF 日志记录以获取有关原始错误的更多信息。这帮助我解决了这个问题。

      将以下内容添加到您的 web.config,它将日志保存到 C:\log\Traces.svclog

      <system.diagnostics>
          <sources>
              <source name="System.ServiceModel"
                        switchValue="Information, ActivityTracing"
                        propagateActivity="true">
                  <listeners>
                      <add name="traceListener"
                           type="System.Diagnostics.XmlWriterTraceListener"
                           initializeData= "c:\log\Traces.svclog" />
                  </listeners>
              </source>
          </sources>
      </system.diagnostics>
      

      【讨论】:

        【解决方案3】:

        在服务器端的 app.config/web.config 中试试这个:

        <system.web>
            <httpRuntime maxRequestLength="109200" executionTimeout="3600" />
        </system.web>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-01-09
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-02-24
          • 2013-06-20
          相关资源
          最近更新 更多