基础连接已经关闭: 无法连接到远程服务器,如何解决!!!!!!!!!!

Anorld 2004-10-09 03:56:35
在写了webservice出现了异常,如何解决呀,急
情况:webservice部署在一台真实ip上面,客户端也用真实ip可以访问,但是客户端改用
内部ip是就不能访问了,出现:

Message:基础连接已经关闭: 无法连接到远程服务器。
StackTrace: at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetRequestStream()
at Microsoft.Web.Services2.SoapWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodN
ame, Object[] parameters)

不知道如何解决!!
...全文
769 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
tongcheng 2004-11-08
  • 打赏
  • 举报
回复
同时还应注意防火墙。。。
tongcheng 2004-11-08
  • 打赏
  • 举报
回复
“如果要通过代理服务器去访问webservice,需要在客户端为webservice的代理类指定代理服务器”
zhongwanli 2004-11-07
  • 打赏
  • 举报
回复
学习中...
Uncommon 2004-11-07
  • 打赏
  • 举报
回复
客户端在调用要求标头的方法之前,直接在代理类上设置标头,如下面的示例所示:


HeaderService h = new HeaderService();
AuthHeader myHeader = new AuthHeader();
myHeader.Username = "JohnDoe";
myHeader.Password = "password";
h.AuthHeader = myHeader;
String result = h.SecureMethod();

请参见
http://chs.gotdotnet.com/quickstart/aspplus/doc/secureservices.aspx
jerry051 2004-11-01
  • 打赏
  • 举报
回复
在程序中需要设置代理服务器!
lql9935 2004-10-14
  • 打赏
  • 举报
回复
up
tongcheng 2004-10-13
  • 打赏
  • 举报
回复
看看
。。。
kevin521 2004-10-12
  • 打赏
  • 举报
回复
关注
zxn1979125 2004-10-11
  • 打赏
  • 举报
回复
客户端改用内部ip后可以上网吗
rottenapple 2004-10-11
  • 打赏
  • 举报
回复
是不是内部局域网设置问题。
CMIC 2004-10-11
  • 打赏
  • 举报
回复
如果在要通过代理服务器去访问webservice,需要在客户端为webservice的代理类指定代理服务器。

这样我访问http://www.webservicex.net/globalweather.asmx时vs.net的生成的代理类的代码,我的代理服务器没有用户名和密码我没法试,不代密码的方法:
其中
System.Net.WebProxy myProxy
=new System.Net.WebProxy("192.1.1.1",8080);
this.Proxy=myProxy;
就是设置代理服务器的代码




[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="GlobalWeatherSoap", Namespace="http://www.webserviceX.NET")]
public class GlobalWeather : System.Web.Services.Protocols.SoapHttpClientProtocol {

/// <remarks/>
public GlobalWeather() {
this.Url = "http://www.webservicex.net/globalweather.asmx";
//指定代理服务器
System.Net.WebProxy myProxy
=new System.Net.WebProxy("192.1.1.1",8080);
this.Proxy=myProxy;
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.webserviceX.NET/GetWeather", RequestNamespace="http://www.webserviceX.NET", ResponseNamespace="http://www.webserviceX.NET", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string GetWeather(string CityName, string CountryName) {
object[] results = this.Invoke("GetWeather", new object[] {
CityName,
CountryName});
return ((string)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BeginGetWeather(string CityName, string CountryName, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("GetWeather", new object[] {
CityName,
CountryName}, callback, asyncState);
}

/// <remarks/>
public string EndGetWeather(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.webserviceX.NET/GetCitiesByCountry", RequestNamespace="http://www.webserviceX.NET", ResponseNamespace="http://www.webserviceX.NET", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string GetCitiesByCountry(string CountryName) {

object[] results = this.Invoke("GetCitiesByCountry", new object[] {
CountryName});

return ((string)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BeginGetCitiesByCountry(string CountryName, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("GetCitiesByCountry", new object[] {
CountryName}, callback, asyncState);
}

/// <remarks/>
public string EndGetCitiesByCountry(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}
}
}
Anorld 2004-10-09
  • 打赏
  • 举报
回复
不是localhost的问题,而是,
客户端可以用真实ip可以访问,但是客户端改用内部ip是就不能访问了
出现了异常,为什么!!!
aquariusdeng 2004-10-09
  • 打赏
  • 举报
回复
试试直接在IE敲地址(内部ip)能不能打开WebService的调试页面

如果不需要用真实的ip访问WebService,最好部署的时候写内部ip,而不要用localhost
cfmowh 2004-10-09
  • 打赏
  • 举报
回复
no 1

12,162

社区成员

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

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