WEB服务代理类的创建

1>创建WEB服务之后,在命令行执行Wsdl.exe工具为服务产生代理类:
Wsdl /l:cs http://localhost:2082/Service1.asmx
2>然后,执行下面的CS命令;编译代理类(通过上面的命令把此服务转化成了类文件)
csc /t: library /r:System.dll,System.Web.Services.dll,System.xml.dll,System.Data.dll  Service1.cs
3>在的ASP.NET项目中引用上面创建的DLL,并且添加对system.web.services的引用
这时就可以在代码中使用了,就象以前一样调用他的方法:
如:

 

代码
ServiceReference1.Service1SoapClient s = new WebApp.ServiceReference1.Service1SoapClient();
if (s.State == System.ServiceModel.CommunicationState.Opened)
{
Response.Write(s.HelloWorld());
}

 

 

posted @ 2010-03-23 08:57  bndy  阅读(152)  评论(0编辑  收藏  举报