问个问题,为什么我创建的webservice在运行后没有提示我的 webmethod 有效, 请看看

SphereEGO 2003-04-27 12:35:20
我的代码:

namespace MyWebService1Test
{
/// <summary>
/// Summary description for Service1.
/// </summary>
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}

#region Component Designer generated code

//Required by the Web Services Designer
private IContainer components = null;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion

// WEB SERVICE EXAMPLE
// The HelloWorld() example service returns the string Hello World
// To build, uncomment the following lines then save and build the project
// To test this web service, press F5

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}

public class ServiceTest : System.Web.Services.WebService
{
[WebMethod]
public int ReturnAdd( int _a , int _b )
{
return _a + _b;
}
}
}

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

运行后的提示为:

The following operations are supported. For a formal definition, please review the Service Description.

HelloWorld

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

我自己写的webmethod怎么没认出来呢?
...全文
42 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jhnhu 2003-04-27
  • 打赏
  • 举报
回复
用另一个.asmx 放你的服务
public class ServiceTest : System.Web.Services.WebService
{
[WebMethod]
public int ReturnAdd( int _a , int _b )
{
return _a + _b;
}
}
SphereEGO 2003-04-27
  • 打赏
  • 举报
回复
毛塞吨开哈~~谢谢
jhnhu 2003-04-27
  • 打赏
  • 举报
回复
1 在你的project上 右键 add->add new item->WebService
你把HelloWorld去掉了 但还是有两个类啊

2 按步骤1添加了新的 .asmx文件后,切换到code view就是另一个 .cs文件了
选则Solution Explorer窗口工具拦里的Show all files就可以看到

3 好象是按顺序来,前面那一个
你把两个class换一下位置试试

more:当一个project里有多个.asmx(或.aspx)时,可以在.asmx上右键set as start page来作为开始页面(调试时自动运行那个)
SphereEGO 2003-04-27
  • 打赏
  • 举报
回复
1:请问用另外一个asmx放我的service是什么意思,能说详细点么?

其实就算我把上面的[WebMetohd] HellowWorld 去掉也一样的结果

2:另外问一下,我是在c#的环境下写的,这里只有一个.asmx.cs的文件啊

3:对了如果一个.asmx.cs的文件里面有几个 class , 到底怎么指定其中一个class为与这个.asmx相关联的呢?

110,570

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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