调用WCF接口时出现“格式化程序尝试对消息反序列化时引发异常....”

调用WCF接口异常信息如下:


格式化程序尝试对消息反序列化时引发异常: 尝试对参数 http://tempuri.org/ 进行反序列化时出错: request。InnerException 消息是“反序列化对象 属于类型 TenantPlatform.WCF.DataContracts.EditSpecialTaskRequest 时出现错误。读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。”。有关详细信息,请参见 InnerException。”。有关详细信息,请参见服务器日志。


web.config文件配置如下:

<bindings>     
      <webHttpBinding>
        <binding name="HttpBinding" maxReceivedMessageSize="2097152">
          <readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" />
          <security mode="None"></security>
        </binding>
      </webHttpBinding>
    </bindings>


另 <services>下面需要配置如下:

  <service behaviorConfiguration="*" name="*">
        <endpoint address="" behaviorConfiguration="httpBehavior" binding="webHttpBinding" bindingConfiguration="HttpBinding"
          contract="*" kind="webHttpEndpoint">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>

最重要的一点是,需要添加   bindingConfiguration="HttpBinding"   “HttpBinding”为 binding节点中的 name属性值。


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值