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

转载于:https://www.cnblogs.com/ListenFly/archive/2013/03/01/2936989.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值