webservice异常:基础连接已关闭

alie 2002-08-02 09:00:59
小弟用c#做了一个桌面应用程序,其中与服务器数据库进行数据交换部分用到了webservice。这个webservice是在内部局域网的服务器中建立的,程序在内部局域网中调试时没问题。把webservice移植到互联网上的服务器进行调试时出现如下问题:程序在启动后,第一次上传数据时没问题,第二次上传数据时可能(并不是每一次)出现以下异常:基础连接已关闭。

另:在内部局域网中,从ie输入webservice的地址,使用Invoke按钮对方法进行测试时没问题;但在互联网上测试时,使用Invoke按钮后出现找不到网页的错误信息。

是否与环境配置有关?请高手指教!!!
...全文
594 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
idiotzeng 2002-11-01
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/library/en-us/dndotnet/html/hawkremoting.asp?frame=true#hawkremoting_topic6
idiotzeng 2002-11-01
  • 打赏
  • 举报
回复
设置LifetimeServices.LeaseTime 属性
idiotzeng 2002-11-01
  • 打赏
  • 举报
回复
不好意思,看错题目,可能回答的跟你问的不是一码事:P
darker 2002-11-01
  • 打赏
  • 举报
回复
我按照你的加了一些代码:

但是结果还是不能调用远程的WEB服务成功
idiotzeng 2002-11-01
  • 打赏
  • 举报
回复
.NET 框架一般参考

<lifetime> 元素请参见
远程处理设置架构 | 激活 | MarshalByRefObject.InitializeLifetimeService
要求
配置文件:应用程序配置文件、计算机配置文件 (Machine.config)


包含有关由此应用程序提供服务的所有客户端激活对象生存期的信息。可通过重写远程类型上的 MarshalByRefObject.InitializeLifetimeService 设置各个对象的特定生存期控件。

<configuration>
<system.runtime.remoting>
<application>
<lifetime>

<lifetime
leaseTime="leasetime"
sponsorshipTimeout="sponsorshipTimeOut"
renewOnCallTime="renewOnCallTime"
leaseManagerPollTime="pollTime"
/>
可选属性
属性 说明
leaseTime 指定该应用程序的租约时间。默认的 leaseTime 为 5 分钟。
sponsorshipTimeout 指定租约管理器得到租约到期通知时等待主办方响应的时间。如果主办方未能在指定时间内响应,则由垃圾回收器处置该远程对象。默认的 sponsorshipTimeout 为 2 分钟。
renewOnCallTime 指定对象上每个函数调用的租约时间的延长时间。默认的 renewOnCallTime 为 2 分钟。
leaseManagerPollTime 指定租约管理器在检查到期租约后休眠的时间。默认的 leaseManagerPollTime 为 10 秒。

备注
<lifetime> 元素具有四种可选属性。每种属性的有效值都由一个十进制数和一个时间单位组成。有效的时间单位为 D(天)、H(小时)、M(分钟)、S(秒)和 MS(毫秒)。如果未指定单位,则默认的时间单位为秒。例如,“10”解释为“10 秒”。

示例
下面的示例将所有的客户端激活对象设置为:租约时间为 5 分钟,主办超时为 2 分钟、每次调用方法时的续订时间为 2 分钟,租约管理器轮询时间为 10 秒。

<lifetime
leaseTime="5M"
sponsorshipTimeOut="2M"
renewOnCallTime="2M"
leaseManagerPollTime="10S"
/>
要求
配置文件:应用程序配置文件、计算机配置文件 (Machine.config)

请参见
远程处理设置架构 | 激活 | MarshalByRefObject.InitializeLifetimeService



--------------------------------------------------------------------------------

将文档反馈发送给 Microsoft

© 2002 Microsoft Corporation。保留所有权利。
darker 2002-11-01
  • 打赏
  • 举报
回复
能否给出例子来
darker 2002-10-31
  • 打赏
  • 举报
回复
有没有人给出详细的解决方法!

版主呢?能不能帮忙解决一下.
DullMan 2002-08-17
  • 打赏
  • 举报
回复
帮你UP!
alie 2002-08-06
  • 打赏
  • 举报
回复
************** 异常文本 **************
System.Net.WebException: 基础连接已经关闭:发送时发生意外错误。
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at CNCO.Soft.DiySite.InserInto_userweb_UploadPages(String _member_id, String _PageFolder, String _PageName, String _PageTitle, String _lm_id, Boolean _is_use) in f:\documents and settings\huanglie.yinde\my documents\visual studio projects\webcenter\web 引用\com.ciebb.diysite\reference.cs:line 657
at CNCO.Soft.UpLoad.SqlInsertData() in f:\documents and settings\huanglie.yinde\my documents\visual studio projects\webcenter\upload.cs:line 1398
at CNCO.Soft.UpLoad.timer1_Tick(Object sender, EventArgs e) in f:\documents and settings\huanglie.yinde\my documents\visual studio projects\webcenter\upload.cs:line 196
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr idEvent, IntPtr dwTime)
12wywy 2002-08-02
  • 打赏
  • 举报
回复
我也遇到上述问题,现在还算比较集中:都出在互联网访问上。本来它就
不稳定,我发现常常出现在
填写postData 语句(FileStream)sr.Write(...)
请求数据语句 (WebRequest)req.GetResponse(...)
我的解决办法是用try捕捉异常


12,165

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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