0
以下是我的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」這兩個屬性來裝飾它們。 當我檢查返回字符串的簡單方法時,它工作正常。 可能是什麼原因?
這是最有可能的反序列化發行後做工精細和完善。在這種情況下,您的配置並不重要。你的「自定義類」是。所以也許你可以展示他們。 –