讲一个例子
新建一个Web Service,在[WebMethod]下添加一个函数或过程
如:
 public string F(int n)
{int s=1;
 for(int i=1;i<=n;i++)s*=i;
 return s.ToString();
 }F5编译运行,生成asmx文件然后在其它程序中就可以使用"添加Web引用"来调用这个Web服务(函数)

解决方案 »

  1.   

    说一下一个手工的WebService 的方法首先:
    建一个个simple.asmx%@ WebService Language="C#" Class="HelloWorld" %>using System;
    using System.Web;
    using System.Web.Services;public class HelloWorld: WebService {
    [WebMethod]
    public string SayHelloWorld() {
    return "Hello World";
    }
    }将之拷到intpub/wwwroot下
    只有一个方法
    然后,在command中利用命令WSDL http://youemachinename/simple.asmx?WSDL /out:HelloWord.cs /namespace:learn上面的命令生成代理类HelloWord.cs,在你的当前命令行目录下将代理类加入你所要调用webservice的工程
    using learn;....void Page_Load(object sender, EventArgs e) {
    HelloWord hello = new HelloWord();
    Response.Write(hello.SayHelloWorld());
    }这样调用就可以,你可以在另外一台机上试,尝试关闭有simple.asmx机器的www服务器,再调用.
      

  2.   

    ms-help://MS.VSCC/MS.MSDNVS.2052/vsintro7/html/vbwlkCreatingDistributedWebApplicationWalkthrough.htm
      

  3.   

    上面的例子中,不用webservice而是直接用CLass好象也是一样的不啊
      

  4.   

    不一样,我可以改变[WebMethod]的内容,但不用生成proxy类,webservice的调用者不必重新拷贝proxy类,你可以看看生成的HelloWorld.cs,其实类似于EJB中的Home接口
      

  5.   

    在beta2版所带的书中有个小例子,讲的很清楚.