zoukankan      html  css  js  c++  java
  • WCF之传递较长字符串(参数)

    最近在做一个WCF端生成word的功能,在Silverlight端调用WCF传递一系列参数之后,发现会出现错误。经过多次测试是因为我传递了图片的byte[]过去,结果导致参数长度超出了限制,就over了。又经过了多方资料的查询,最终得到了解决方案,主要是对web.config进行正确的配置,代码如下:

    <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="FileServiceBehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
            multipleSiteBindingsEnabled="true" />
        <services>
          <service behaviorConfiguration="FileServiceBehavior" name="RichTextBoxDemo.Web.FileService">
            <endpoint address="" bindingConfiguration="basicHttpBinding_Generic" binding="basicHttpBinding" contract="RichTextBoxDemo.Web.IFileService"/>
          </service>
        </services>
    
        <bindings>
          <basicHttpBinding>
            <binding name="basicHttpBinding_Generic"
                     allowCookies="false" bypassProxyOnLocal="false"
         hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2147483647" 
         maxBufferPoolSize="2147483647"
         maxReceivedMessageSize="2147483647"
         messageEncoding="Text" textEncoding="utf-8"
         transferMode="Streamed"
         useDefaultWebProxy="true">
              <readerQuotas maxDepth="2147483647"  maxStringContentLength="2147483647" maxArrayLength="2147483647"  maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
              <security mode="None">
                <transport clientCredentialType="None"
                        proxyCredentialType="None" realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
      </system.serviceModel>

     注意 长度为  "2147483647"的地方就是要注意和修改的地方,好了,再次打开你的程序传递较长的字符串(其他类型)会神奇的发现,没有出现NonFound错误。

  • 相关阅读:
    case when then用法
    查询后n条记录
    自定义函数
    字符函数
    数字运算符和函数
    时间日期函数
    mysql加密函数
    比较运算符和函数
    文件夹中的文件以目录的形式呈现
    错误提示:通过 Web 服务器的身份验证的用户无权打开文件系统上的文件
  • 原文地址:https://www.cnblogs.com/ListenFly/p/2936989.html
Copyright © 2011-2022 走看看