Web Service & Client

 

 [Web Client using Console]

> Wsdl http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?WSDL

 

Copy WeatherWebService.cs to Solution and add it

using System;
using System.Collections.Generic;
using System.Text;
namespace weather
{
    class Program
    {
        static void Main(string[] args)
        {
            string strName = null;
            if (args.Length > 0) strName = args[0];
            else strName = "上海";
            WeatherWebService wws = new WeatherWebService();
            string[] info = wws.getWeatherbyCityName(strName);
            Console.WriteLine("省份:/t/t{0}", info[0]);
            Console.WriteLine("城市:/t/t{0}", info[1]);
            Console.WriteLine("最後更新時間:/t{0}", info[4]);
            Console.WriteLine("今日氣溫:/t{0}", info[5]);
            Console.WriteLine("明日氣溫:/t{0}", info[12]);
            Console.WriteLine("後天氣溫:/t{0}", info[17]);
            Console.ReadLine();
        }
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章