底层连接已关闭:连接意外关闭

时间:2013-01-22 06:42:41

标签: wcf

以下是我的web.config文件中的服务模型配置:

    <system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
        <serviceMetadata httpGetEnabled="true" />
        <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
        <serviceDebug includeExceptionDetailInFaults="true" />
        <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_IDataPortal" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
       allowCookies="false" bypassProxyOnLocal="true" hostNameComparisonMode="StrongWildcard"
       maxBufferPoolSize="524288" maxBufferSize="65536" maxReceivedMessageSize="65536"
       textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
        <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096"
                      maxNameTableCharCount="2147483647"/>
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None" realm=""></transport>
          <message clientCredentialType="UserName" algorithmSuite="Default"/>
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://localhost:4481/MyDataService.svc"
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IDataPortal"
              name="BasicHttpBinding_IDataPortal"
              contract="eBusiness_Core.Contracts.ServiceContracts.IBusinessData">
    </endpoint>
  </client>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

当我检查WCF测试客户端中WCF方法的执行时,它会执行调用,但最后会返回一个异常,说“基础连接已关闭:连接意外关闭”。 我在我的WCF服务中使用了自定义类型,并且我使用“DataContract”和“Serializable”这两个属性进行了装饰。 当我检查返回字符串的简单方法时,它工作正常。 可能是什么原因?

1 个答案:

答案 0 :(得分:0)

在升级POCO生成器类以使用EF 5.0

之后,这开始工作正常并且完美