使用应用程序访问webservice功能

1.建立webservice
2.建立代理类
 2.1
使用WSDL.EXE生成代理类
D:\temp>WSDL /out:myWebService.cs http://localhost/MathService/Service1.asmx
Microsoft (R) Web 服务描述语言实用工具
[Microsoft (R) .NET Framework,版本 1.1.4322.573]
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

正在写入文件“myWebService.cs”。

2.2
CSC生成cs文件的DLL文件
D:\temp>csc /out:myWebService.dll /t:library /r:system.xml.dll /r:system.web.services.dll  myWebService.cs
生成客户端程序
csc /r:myWebService.dll CallWebService.cs

客户端中的内容
using System;

class WebServiceTest
{
 static void Main()
 {
    //
   MyService myService = new MyService();//这里的MyService的类名与代理类中的类名要一至
   double db1 = double.Parse(Console.ReadLine());
   double db2 = double.Parse(Console.ReadLine());
   double dbResult = myService.WebAdd(db1,db2);
   Console.WriteLine("结果为:"+dbResult.ToString());
 }
}


 

原文地址:https://www.cnblogs.com/hhq80/p/658190.html