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错误。

  • 相关阅读:
    对话框中设置静态文本框字体及颜色
    UVA 10250 The Other Two Trees(几何)
    UVA 113 Power of Cryptography(数学)
    VC++设置半透明界面
    UVA 10474 Where is the Marble?
    UVA 123 Searching Quickly(分离单词)
    为对话框在标题栏和任务栏关联图标
    UVA 152 Tree's a Crowd
    UVA 156 Ananagrams
    UVA 299 Train Swapping(冒泡排序)
  • 原文地址:https://www.cnblogs.com/ListenFly/p/2936989.html
Copyright © 2011-2022 走看看