zoukankan      html  css  js  c++  java
  • Android upload large file to WCF restful service

    WCF服务默认处理的最大消息大小:65536字节,

    http://msdn.microsoft.com/zh-cn/library/system.servicemodel.webhttpbinding.maxreceivedmessagesize.aspx

    如果需要服务可以接受更大的数据消息,可以通过web.config修改配置信息: 

     <httpRuntime targetFramework="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=********" executionTimeout="300" maxRequestLength="10240" />
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IDotNetWebService" />
            <binding name="BasicHttpBinding_IPdsService" />
        </basicHttpBinding>
        <webHttpBinding>
            <!-- Limits set to 10 MB (specified value in bytes) -->
            <binding name="ApiQuotaBinding" maxReceivedMessageSize="10485760" maxBufferPoolSize="10485760" maxBufferSize="10485760" >
              <readerQuotas maxDepth="32" maxStringContentLength="10485760" maxArrayLength="10485760" maxBytesPerRead="10485760" />
              <security mode="None" />
            </binding>
        </webHttpBinding>     
    </bindings>

    然后在endpoint上指定bindingConfiguration:

     <services>
          <service name="MobilePlatWcfService.Web.Services.MobileRestWebService">
            <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="ApiQuotaBinding"
              contract="MobilePlatWcfService.Web.Services.IMobileRestWebService" />
       </service>
     </services>

    ======================================

    下面配置为指定webhttp响应格式为JSON格式:

     <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior name="web">
              <webHttp defaultOutgoingResponseFormat="Json"/>
            </behavior>
         </endpointBehaviors>
     </behaviors>

      

  • 相关阅读:
    prometheus — nginx-vts-exporter
    jenkins的sbt插件安装
    centos 踩坑集锦
    Prometheus — Process-exporter进程监控
    Prometheus 自定义exporter 监控key
    prometheus — 基于文件的服务发现
    Prometheus 企业微信报警/inhibit抑制 /静默(二)
    centos7-- sbt的安装使用
    prometheus + grafana + node_exporter + alertmanager 的安装部署与邮件报警 (一)
    nginx配置
  • 原文地址:https://www.cnblogs.com/xl0715/p/3476729.html
Copyright © 2011-2022 走看看