简单Web Service出现问题

dawnhorizon 2004-03-15 11:21:14
仅仅利用.net自己带的那个HelloWorld的服务,然后我添加了一个ASP.NET,
private void Button1_Click(object sender, System.EventArgs e)
{
localhost.Service1 ws1 = new localhost.Service1();

TextBox1.Text = ws1.HelloWorld();
}

就出现以下错误,怎么回事啊?




Server Error in '/HelloWorldApp' Application.
--------------------------------------------------------------------------------

The underlying connection was closed: Unable to connect to the remote server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server.

Source Error:


Line 35: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/HelloWorld", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 36: public string HelloWorld() {
Line 37: object[] results = this.Invoke("HelloWorld", new object[0]);
Line 38: return ((string)(results[0]));
Line 39: }

...全文
31 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
oldxu 2004-04-20
  • 打赏
  • 举报
回复
不要用localhost,用127.0.0.1
zhhahuatian 2004-04-19
  • 打赏
  • 举报
回复
在解决方案中加入引用,然后再事例化就了一了
zhjboss 2004-04-18
  • 打赏
  • 举报
回复
你没有增加引用吗?要增加引用啊,这样能用,先添加引用,然后
using 你的名字空间
HelloWorld ww=new HelloWorld();
TextBox1.Text = ws1.HelloWorld();
zhangpmax 2004-04-17
  • 打赏
  • 举报
回复
URL 错误,在解决方案里的LOCALHOST改URL 地址加上你的IP
dawnhorizon 2004-04-06
  • 打赏
  • 举报
回复
还是不行。是不是我的IIS有问题?
gotocool 2004-03-20
  • 打赏
  • 举报
回复
你先添加WEB服务引用,在LOCALHOST属性中URL行为设为动态,在CS中添加 using 命名空间。LOCALHOST; 再添加如下代码就可以了
Service1 opj=new Service1();
this.Label1.Text=opj.HelloWorld();
dawnhorizon 2004-03-17
  • 打赏
  • 举报
回复
急。
qm0445 2004-03-17
  • 打赏
  • 举报
回复
add a web reference
rottenapple 2004-03-17
  • 打赏
  • 举报
回复
add a web reference
dawnhorizon 2004-03-17
  • 打赏
  • 举报
回复
在同一个机器上啊:(
lr2651 2004-03-17
  • 打赏
  • 举报
回复
你的aspx页和WebService不在同一台机器上吗?
dawnhorizon 2004-03-17
  • 打赏
  • 举报
回复
顶。
dawnhorizon 2004-03-17
  • 打赏
  • 举报
回复
顶。
dawnhorizon 2004-03-17
  • 打赏
  • 举报
回复
Add a web reference 以及jamzh老兄的方法都试过了,还是不行。错误是连不上远端服务器,会是什么原因呢?
dawnhorizon 2004-03-16
  • 打赏
  • 举报
回复
re
jamzh 2004-03-16
  • 打赏
  • 举报
回复
你的WebServices 的URL地址错误。或你连接WebServices所在的服务器连接不上
你可以在代码中加一段
private void Button1_Click(object sender, System.EventArgs e)
{
localhost.Service1 ws1 = new localhost.Service1();
ws1.url="http://Servername/xxx/WebSerives.asmx"

TextBox1.Text = ws1.HelloWorld();
}

huangsuipeng 2004-03-15
  • 打赏
  • 举报
回复
up

12,162

社区成员

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

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