天天看点

由无法调试WCF引发的一些故事

Silverlight调用WCF,无法跟进WCF代码,用WCF测试器测试后发现传输字符太长。

百度了一下,加上

<readerQuotas maxDepth="32" maxStringContentLength="2147483647"

           maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />

这样的配置,本以为问题解决,但是发现依然如故。

一高手前来相助,调试很久,发现没有配置另外两个节点。摘贴如下。

一是需要这样的节点

<system.serviceModel>

  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false"/>

  <behaviors>

    <serviceBehaviors>

      <behavior name="Import">

        <serviceMetadata httpGetEnabled="true"/>

        <serviceDebug includeExceptionDetailInFaults="false"/>

        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>

      </behavior>

……

……

<services>

       <service behaviorConfiguration="Import" name="Import">

        <endpoint address="" bindingConfiguration="ImportSoap" binding="basicHttpBinding" contract="Import"/>

      </service>

  </services>

这两个节点的意义不是很明白,MSDN了一下:

<behaviors>

此节定义名为 endpointBehaviors 和 serviceBehaviors 的两个子集合。每个集合分别定义终结点和服务所使用的行为元素。每个行为元素由其唯一的 name 特性标识。

架构层次结构

<system.serviceModel>

语法

<behaviors>

   <serviceBehaviors>

   </serviceBehaviors>

   <endpointBehaviors>

   </endpointBehaviors>

</behaviors>

http://msdn.microsoft.com/zh-cn/site/ms731303

<service>

service 元素包含 Windows Communication Foundation (WCF) 服务的设置。它还包含公开此服务的终结点。

<system.serviceModel>

<services>

<service behaviorConfiguration=String"

        name="String"

&lt;/service>

属性和元素

以下几节描述了属性、子元和父元素。

说明

behaviorConfiguration

一个字符串,其中包含要用于实例化服务的行为的行为名。定义服务时,该行为名必须在作用域内。默认值为空字符串。

name

必需的字符串属性,此属性指定要进行实例化的服务的类型。此设置必须等同于一个有效类型。格式应为 Namespace.Class.

子元素

<endpoint> 元素

公开此服务的 endpoint 元素的集合。

<host>

指定此服务实例的主机。此元素的类型为 HostElement。

父元素

<services>

所有 WCF 配置元素的根元素。

备注