連接WCF服務報錯:"基础连接已经关闭: 服务器关闭了本应保持活动状态的连接."

编程爱好者L 2011-03-28 09:35:35
如題!!!!
...全文
2600 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
kslynn 2013-12-07
  • 打赏
  • 举报
回复
我也遇到了这个问题. 的确. DataTable 在使用时必须指定表名, 否则会报错. 受教了.
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 fangxinggood 的回复:]
<endpoint address="http://localhost:5500/ExampleService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding"
contract="ExampleService.IExampleService" name="WSHttpBinding">
<iden……
[/Quote]
名字改好了,但還是不行~
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 dongxinxi 的回复:]
去系统日志里看看,是否有什么服务异常中止了
[/Quote]
下面是日誌:
#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2011-03-28 02:31:42
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2011-03-28 02:31:42 ::1 GET /Default2.aspx - 4111 - ::1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.1;+WOW64;+Trident/4.0;+TencentTraveler+4.0;+QQDownload+677;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+.NET4.0C;+InfoPath.1;+.NET4.0E) 500 19 5 0
2011-03-28 02:34:59 ::1 GET /Default2.aspx - 4111 - ::1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.1;+WOW64;+Trident/4.0;+TencentTraveler+4.0;+QQDownload+677;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+.NET4.0C;+InfoPath.1;+.NET4.0E) 500 19 5 0
#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2011-03-28 02:38:09
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2011-03-28 02:38:09 ::1 GET /Default2.aspx - 8080 - ::1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.1;+WOW64;+Trident/4.0;+TencentTraveler+4.0;+QQDownload+677;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+.NET4.0C;+InfoPath.1;+.NET4.0E) 500 0 0 64602
2011-03-28 02:40:32 ::1 GET /Default2.aspx - 8080 - ::1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.1;+WOW64;+Trident/4.0;+TencentTraveler+4.0;+QQDownload+677;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+.NET4.0C;+InfoPath.1;+.NET4.0E) 500 0 0 5062

机器人 2011-03-28
  • 打赏
  • 举报
回复
<endpoint address="http://localhost:5500/ExampleService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding"
contract="ExampleService.IExampleService" name="WSHttpBinding">
<identity>
<servicePrincipalName value="host/pc-lgl" />
</identity>
</endpoint>
<endpoint address="http://localhost:5500/UserInfoService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding"
contract="UserInfoService.IUserInfoService" name="WSHttpBinding">
<identity>
<servicePrincipalName value="host/pc-lgl" />
</identity>
</endpoint>
客户端两个endpoint 名字重复了,改成不重复的试一下。
  • 打赏
  • 举报
回复
去系统日志里看看,是否有什么服务异常中止了
西门喷血 2011-03-28
  • 打赏
  • 举报
回复









论坛签名======================================================================

qq123592624:你好!
截至 2011-03-28 09:35:35 前:
你已发帖 58 个, 未结贴 3 个;
结贴率为: 94.83%
zhuxueliao 2011-03-28
  • 打赏
  • 举报
回复
就是连接数据库那的问题 再仔细的看一遍
Nick黄 2011-03-28
  • 打赏
  • 举报
回复
就是不告诉你
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
這個是客戶端配置文件:
 <system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:5500/ExampleService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding"
contract="ExampleService.IExampleService" name="WSHttpBinding">
<identity>
<servicePrincipalName value="host/pc-lgl" />
</identity>
</endpoint>
<endpoint address="http://localhost:5500/UserInfoService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding"
contract="UserInfoService.IUserInfoService" name="WSHttpBinding">
<identity>
<servicePrincipalName value="host/pc-lgl" />
</identity>
</endpoint>
</client>
</system.serviceModel>
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
這是服務器配置文件:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="UcsmyEntities" connectionString="metadata=res://*/Ucsmy.csdl|res://*/Ucsmy.ssdl|res://*/Ucsmy.msl;provider=System.Data.SqlClient;provider connection string="Data Source=LESLIE-PC;Initial Catalog=MySQL;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<appSettings>
<add key="SqlDAL" value="Ucsmy.Portal.DAL"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<services>
<!--ExampleService-->
<service name="Ucsmy.Portal.Service.ExampleService" behaviorConfiguration="testServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="Ucsmy.Portal.Service.IExampleService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
<!--UserinfoService-->
<service name="Ucsmy.Portal.Service.UserInfoService" behaviorConfiguration="testServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="Ucsmy.Portal.Service.IUserInfoService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="testServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
机器人 2011-03-28
  • 打赏
  • 举报
回复
服务端配置文件,和客户端配置文件,分别贴出来看看。
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhuxueliao 的回复:]
看看你所有的连接都关闭了吗
[/Quote]
這個服務我是用來測試的,裏面只有一個查詢數據的方法,在客戶端調用這個方法就報錯了
zhuxueliao 2011-03-28
  • 打赏
  • 举报
回复
看看你所有的连接都关闭了吗
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fangxinggood 的回复:]
http://www.cnblogs.com/frank_xl/archive/2009/03/15/1412712.html

先确认下metadata能否通过url访问?
[/Quote]
可以通過url訪問,服務端運行沒問題,就是到客戶端調用的時候就出現這個錯誤了
机器人 2011-03-28
  • 打赏
  • 举报
回复
http://www.cnblogs.com/frank_xl/archive/2009/03/15/1412712.html

先确认下metadata能否通过url访问?
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
[Quote=引用 25 楼 fangxinggood 的回复:]
如果要结合 Linq2Entities, 你可以直接去看看 WCF Data Services
[/Quote]
這個我回去看看 呼呼...兩天的問題終於解決
编程爱好者L 2011-03-28
  • 打赏
  • 举报
回复
[Quote=引用 24 楼 fangxinggood 的回复:]
linq默认是延迟加载,这个地方你最好 .ToList() 一下。

我不知道对于 IEnumable的返回值,WCF怎么做得序列化。

定义 OperationContract 应该是 List<T> 这样。
[/Quote]
果然是這樣,謝謝了,問題解決
机器人 2011-03-28
  • 打赏
  • 举报
回复
如果要结合 Linq2Entities, 你可以直接去看看 WCF Data Services
机器人 2011-03-28
  • 打赏
  • 举报
回复
linq默认是延迟加载,这个地方你最好 .ToList() 一下。

我不知道对于 IEnumable的返回值,WCF怎么做得序列化。

定义 OperationContract 应该是 List<T> 这样。
加载更多回复(8)

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧