程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> csharp: get Web.Services WebMethod,csharpweb.services

csharp: get Web.Services WebMethod,csharpweb.services

編輯:C#入門知識

csharp: get Web.Services WebMethod,csharpweb.services


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services.Description;
using System.Web.Services.Protocols;
using System.Web.Services.Discovery;
using System.Web.Services;
using System.Net;
using System.IO;
using System.CodeDom;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
using System.Reflection;
using System.Text;

namespace WebServerProjectDemo
{
    /// <summary>
    /// 
    /// </summary>
    public class WebServiceHelper
    {
        #region InvokeWebService
        /// <summary>
        /// 
        /// </summary>
        /// <param name="url"></param>
        /// <param name="methodname"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public static object InvokeWebService(string url, string methodname, object[] args)
        {
            return WebServiceHelper.InvokeWebService(url, null, methodname, args);
        }
        /// <summary> 
        /// 動態調用WebService 
        /// </summary> 
        /// <param name="url">WebService地址</param> 
        /// <param name="classname">類名</param> 
        /// <param name="methodname">方法名(模塊名)</param> 
        /// <param name="args">參數列表</param> 
        /// <returns>object</returns> 
        public static object InvokeWebService(string url, string classname, string methodname, object[] args)
        {
            string @namespace = "ServiceBase.WebService.DynamicWebLoad";
            if (classname == null || classname == "")
            {
                classname = WebServiceHelper.GetClassName(url);
            }
            //獲取服務描述語言(WSDL) 
            WebClient wc = new WebClient();
            Stream stream = wc.OpenRead(url + "?WSDL");
            ServiceDescription sd = ServiceDescription.Read(stream);
            ServiceDescriptionImporter sdi = new ServiceDescriptionImporter();
            sdi.AddServiceDescription(sd, "", "");
            CodeNamespace cn = new CodeNamespace(@namespace);
            //生成客戶端代理類代碼 
            CodeCompileUnit ccu = new CodeCompileUnit();
            ccu.Namespaces.Add(cn);
            sdi.Import(cn, ccu);
            CSharpCodeProvider csc = new CSharpCodeProvider();
            ICodeCompiler icc = csc.CreateCompiler();
            //設定編譯器的參數 
            CompilerParameters cplist = new CompilerParameters();
            cplist.GenerateExecutable = false;
            cplist.GenerateInMemory = true;
            cplist.ReferencedAssemblies.Add("System.dll");
            cplist.ReferencedAssemblies.Add("System.XML.dll");
            cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
            cplist.ReferencedAssemblies.Add("System.Data.dll");
            //編譯代理類 
            CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu);
            if (true == cr.Errors.HasErrors)
            {
                System.Text.StringBuilder sb = new StringBuilder();
                foreach (CompilerError ce in cr.Errors)
                {
                    sb.Append(ce.ToString());
                    sb.Append(System.Environment.NewLine);
                }
                throw new Exception(sb.ToString());
            }
            //生成代理實例,並調用方法 
            System.Reflection.Assembly assembly = cr.CompiledAssembly;
            Type t = assembly.GetType(@namespace + "." + classname, true, true);
            object obj = Activator.CreateInstance(t);
            System.Reflection.MethodInfo mi = t.GetMethod(methodname);
            return mi.Invoke(obj, args);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        private static string GetClassName(string url)
        {
            string[] parts = url.Split('/');
            string[] pps = parts[parts.Length - 1].Split('.');
            return pps[0];
        }

        #endregion
    }
}

  測試1

            string url = "http://www.webservicex.net/globalweather.asmx";
            string[] args = new string[2];
            args[0] = "shenzhen";
            args[1] = "China";
            object result = WebServiceHelper.InvokeWebService(url, "GetWeather", args);
            this.label_Result.Text = result.ToString();

  原結果:

 

<string xmlns="http://www.webserviceX.NET">
<?xml version="1.0" encoding="utf-16"?> <CurrentWeather> <Location>Shenzhen, China (ZGSZ) 22-33N 114-06E 18M</Location> <Time>Jun 25, 2015 - 10:00 AM EDT / 2015.06.25 1400 UTC</Time> <Wind> from the SSE (150 degrees) at 13 MPH (12 KT):0</Wind> <Visibility> greater than 7 mile(s):0</Visibility> <SkyConditions> mostly clear</SkyConditions> <Temperature> 84 F (29 C)</Temperature> <DewPoint> 78 F (26 C)</DewPoint> <RelativeHumidity> 83%</RelativeHumidity> <Pressure> 29.68 in. Hg (1005 hPa)</Pressure> <Status>Success</Status> </CurrentWeather>
</string>

  

 

測試2

 try
            {
                /*
                 * http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx
                 getDomesticAirlinesTime
                獲得航班時刻表 DataSet
                輸入參數:startCity = 出發城市(中文城市名稱或縮寫、空則默認:上海);lastCity = 抵達城市(中文城市名稱或縮寫、空則默認:北京);theDate = 出發日期(String 格式:yyyy-MM-dd,如:2007-07-02,空則默認當天);userID = 商業用戶ID(免費用戶不需要)
                返回數據:DataSet,Table(0)結構為 Item(Company)航空公司、Item(AirlineCode)航班號、Item(StartDrome)出發機場、Item(ArriveDrome)到達機場、Item(StartTime)出發時間、Item(ArriveTime)到達時間、Item(Mode)機型、Item(AirlineStop)經停、Item(Week)飛行周期(星期)
                 */
                string url = "http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx";
                string[] args = new string[4];
                args[0] = "上海";
                args[1] = "北京";
                args[2] = "2015-6-25";//當天時間
                args[3] = "";
                object result = WebServiceHelper.InvokeWebService(url, "getDomesticAirlinesTime", args);
                DataSet dsetAirline = result as DataSet;
                this.GridView1.DataSource = dsetAirline.Tables[0];
                this.GridView1.DataBind();
                Response.Write(dsetAirline.Tables[0].Rows.Count.ToString());
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message.ToString());
            }

  查詢原結果:

<DataSet xmlns="http://WebXml.com.cn/">
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="Airlines">
<xs:element name="Airlines" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="AirlinesTime">
<xs:complexType>
<xs:sequence>
<xs:element name="Company" type="xs:string" minOccurs="0"/>
<xs:element name="AirlineCode" type="xs:string" minOccurs="0"/>
<xs:element name="StartDrome" type="xs:string" minOccurs="0"/>
<xs:element name="ArriveDrome" type="xs:string" minOccurs="0"/>
<xs:element name="StartTime" type="xs:string" minOccurs="0"/>
<xs:element name="ArriveTime" type="xs:string" minOccurs="0"/>
<xs:element name="Mode" type="xs:string" minOccurs="0"/>
<xs:element name="AirlineStop" type="xs:string" minOccurs="0"/>
<xs:element name="Week" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<Airlines xmlns="">
<AirlinesTime diffgr:id="AirlinesTime1" msdata:rowOrder="0">
<Company>東方航空</Company>
<AirlineCode>MU5137</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>07:00</StartTime>
<ArriveTime>09:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime2" msdata:rowOrder="1">
<Company>南方航空</Company>
<AirlineCode>CZ9916</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>07:00</StartTime>
<ArriveTime>09:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime3" msdata:rowOrder="2">
<Company>深圳航空</Company>
<AirlineCode>ZH1858</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>07:55</StartTime>
<ArriveTime>10:10</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12346</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime4" msdata:rowOrder="3">
<Company>中國國航</Company>
<AirlineCode>CA1858</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>07:55</StartTime>
<ArriveTime>10:10</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12346</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime5" msdata:rowOrder="4">
<Company>東方航空</Company>
<AirlineCode>MU5101</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>08:00</StartTime>
<ArriveTime>10:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime6" msdata:rowOrder="5">
<Company>南方航空</Company>
<AirlineCode>CZ9889</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>08:00</StartTime>
<ArriveTime>10:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime7" msdata:rowOrder="6">
<Company>海南航空</Company>
<AirlineCode>HU7604</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>08:25</StartTime>
<ArriveTime>10:50</ArriveTime>
<Mode>738</Mode>
<AirlineStop>0</AirlineStop>
<Week>13456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime8" msdata:rowOrder="7">
<Company>東方航空</Company>
<AirlineCode>MU5145</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>08:30</StartTime>
<ArriveTime>10:40</ArriveTime>
<Mode>76A</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime9" msdata:rowOrder="8">
<Company>南方航空</Company>
<AirlineCode>CZ9920</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>08:30</StartTime>
<ArriveTime>10:40</ArriveTime>
<Mode>76A</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime10" msdata:rowOrder="9">
<Company>深圳航空</Company>
<AirlineCode>ZH1590</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>08:55</StartTime>
<ArriveTime>11:15</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>13456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime11" msdata:rowOrder="10">
<Company>中國國航</Company>
<AirlineCode>CA1590</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>08:55</StartTime>
<ArriveTime>11:15</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>13456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime12" msdata:rowOrder="11">
<Company>東方航空</Company>
<AirlineCode>MU5103</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>09:00</StartTime>
<ArriveTime>11:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime13" msdata:rowOrder="12">
<Company>南方航空</Company>
<AirlineCode>CZ9890</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>09:00</StartTime>
<ArriveTime>11:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime14" msdata:rowOrder="13">
<Company>東方航空</Company>
<AirlineCode>MU5129</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>09:20</StartTime>
<ArriveTime>11:55</ArriveTime>
<Mode>325</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime15" msdata:rowOrder="14">
<Company>南方航空</Company>
<AirlineCode>CZ9883</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>09:20</StartTime>
<ArriveTime>11:55</ArriveTime>
<Mode>325</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime16" msdata:rowOrder="15">
<Company>東方航空</Company>
<AirlineCode>MU5139</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>09:30</StartTime>
<ArriveTime>11:55</ArriveTime>
<Mode>76A</Mode>
<AirlineStop>0</AirlineStop>
<Week>2346日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime17" msdata:rowOrder="16">
<Company>南方航空</Company>
<AirlineCode>CZ9918</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>09:30</StartTime>
<ArriveTime>11:55</ArriveTime>
<Mode>76A</Mode>
<AirlineStop>0</AirlineStop>
<Week>2346日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime18" msdata:rowOrder="17">
<Company>東方航空</Company>
<AirlineCode>MU5105</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>10:00</StartTime>
<ArriveTime>12:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime19" msdata:rowOrder="18">
<Company>吉祥航空</Company>
<AirlineCode>HO1721</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>10:00</StartTime>
<ArriveTime>12:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime20" msdata:rowOrder="19">
<Company>南方航空</Company>
<AirlineCode>CZ9892</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>10:00</StartTime>
<ArriveTime>12:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime21" msdata:rowOrder="20">
<Company>深圳航空</Company>
<AirlineCode>ZH1832</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>10:55</StartTime>
<ArriveTime>13:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>145</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime22" msdata:rowOrder="21">
<Company>中國國航</Company>
<AirlineCode>CA1832</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>10:55</StartTime>
<ArriveTime>13:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>145</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime23" msdata:rowOrder="22">
<Company>東方航空</Company>
<AirlineCode>MU5107</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>11:00</StartTime>
<ArriveTime>13:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime24" msdata:rowOrder="23">
<Company>南方航空</Company>
<AirlineCode>CZ9894</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>11:00</StartTime>
<ArriveTime>13:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime25" msdata:rowOrder="24">
<Company>海南航空</Company>
<AirlineCode>HU7606</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>11:25</StartTime>
<ArriveTime>13:45</ArriveTime>
<Mode>738</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime26" msdata:rowOrder="25">
<Company>深圳航空</Company>
<AirlineCode>ZH1836</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>11:30</StartTime>
<ArriveTime>13:55</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime27" msdata:rowOrder="26">
<Company>中國國航</Company>
<AirlineCode>CA1836</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>11:30</StartTime>
<ArriveTime>13:55</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime28" msdata:rowOrder="27">
<Company>吉祥航空</Company>
<AirlineCode>HO1902</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>11:55</StartTime>
<ArriveTime>14:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>23456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime29" msdata:rowOrder="28">
<Company>深圳航空</Company>
<AirlineCode>ZH1502</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>11:55</StartTime>
<ArriveTime>14:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>23456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime30" msdata:rowOrder="29">
<Company>中國國航</Company>
<AirlineCode>CA1502</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>11:55</StartTime>
<ArriveTime>14:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>23456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime31" msdata:rowOrder="30">
<Company>東方航空</Company>
<AirlineCode>MU3185</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>12:00</StartTime>
<ArriveTime>14:20</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime32" msdata:rowOrder="31">
<Company>東方航空</Company>
<AirlineCode>MU5109</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>12:00</StartTime>
<ArriveTime>14:25</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime33" msdata:rowOrder="32">
<Company>南方航空</Company>
<AirlineCode>CZ3908</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>12:00</StartTime>
<ArriveTime>14:20</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime34" msdata:rowOrder="33">
<Company>南方航空</Company>
<AirlineCode>CZ9896</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>12:00</StartTime>
<ArriveTime>14:25</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime35" msdata:rowOrder="34">
<Company>廈門航空</Company>
<AirlineCode>MF1764</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>12:00</StartTime>
<ArriveTime>14:20</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime36" msdata:rowOrder="35">
<Company>東方航空</Company>
<AirlineCode>MU564</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>12:20</StartTime>
<ArriveTime>14:45</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>4</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime37" msdata:rowOrder="36">
<Company>海南航空</Company>
<AirlineCode>HU7608</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>12:35</StartTime>
<ArriveTime>14:55</ArriveTime>
<Mode>738</Mode>
<AirlineStop>0</AirlineStop>
<Week>1345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime38" msdata:rowOrder="37">
<Company>東方航空</Company>
<AirlineCode>MU5111</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>13:00</StartTime>
<ArriveTime>15:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime39" msdata:rowOrder="38">
<Company>南方航空</Company>
<AirlineCode>CZ9898</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>13:00</StartTime>
<ArriveTime>15:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime40" msdata:rowOrder="39">
<Company>東方航空</Company>
<AirlineCode>MU9103</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>13:30</StartTime>
<ArriveTime>15:55</ArriveTime>
<Mode>75B</Mode>
<AirlineStop>0</AirlineStop>
<Week>4</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime41" msdata:rowOrder="40">
<Company>上海航空</Company>
<AirlineCode>FM9103</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>13:30</StartTime>
<ArriveTime>15:55</ArriveTime>
<Mode>75B</Mode>
<AirlineStop>0</AirlineStop>
<Week>4</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime42" msdata:rowOrder="41">
<Company>東方航空</Company>
<AirlineCode>MU5113</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>14:00</StartTime>
<ArriveTime>16:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime43" msdata:rowOrder="42">
<Company>南方航空</Company>
<AirlineCode>CZ9900</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>14:00</StartTime>
<ArriveTime>16:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime44" msdata:rowOrder="43">
<Company>東方航空</Company>
<AirlineCode>MU272</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>14:10</StartTime>
<ArriveTime>16:40</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime45" msdata:rowOrder="44">
<Company>東方航空</Company>
<AirlineCode>MU5147</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>14:30</StartTime>
<ArriveTime>16:50</ArriveTime>
<Mode>76A</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime46" msdata:rowOrder="45">
<Company>南方航空</Company>
<AirlineCode>CZ9922</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>14:30</StartTime>
<ArriveTime>16:50</ArriveTime>
<Mode>76A</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime47" msdata:rowOrder="46">
<Company>深圳航空</Company>
<AirlineCode>ZH1558</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>14:55</StartTime>
<ArriveTime>17:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>2456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime48" msdata:rowOrder="47">
<Company>中國國航</Company>
<AirlineCode>CA1558</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>14:55</StartTime>
<ArriveTime>17:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>2456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime49" msdata:rowOrder="48">
<Company>東方航空</Company>
<AirlineCode>MU5115</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>15:00</StartTime>
<ArriveTime>17:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime50" msdata:rowOrder="49">
<Company>南方航空</Company>
<AirlineCode>CZ9902</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>15:00</StartTime>
<ArriveTime>17:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime51" msdata:rowOrder="50">
<Company>東方航空</Company>
<AirlineCode>MU5117</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>16:00</StartTime>
<ArriveTime>18:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime52" msdata:rowOrder="51">
<Company>南方航空</Company>
<AirlineCode>CZ9904</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>16:00</StartTime>
<ArriveTime>18:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime53" msdata:rowOrder="52">
<Company>深圳航空</Company>
<AirlineCode>ZH1884</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>16:15</StartTime>
<ArriveTime>18:40</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime54" msdata:rowOrder="53">
<Company>中國國航</Company>
<AirlineCode>CA1884</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>16:15</StartTime>
<ArriveTime>18:40</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime55" msdata:rowOrder="54">
<Company>吉祥航空</Company>
<AirlineCode>HO1904</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>16:55</StartTime>
<ArriveTime>19:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime56" msdata:rowOrder="55">
<Company>深圳航空</Company>
<AirlineCode>ZH1518</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>16:55</StartTime>
<ArriveTime>19:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime57" msdata:rowOrder="56">
<Company>中國國航</Company>
<AirlineCode>CA1518</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>16:55</StartTime>
<ArriveTime>19:15</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime58" msdata:rowOrder="57">
<Company>東方航空</Company>
<AirlineCode>MU5119</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:00</StartTime>
<ArriveTime>19:25</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime59" msdata:rowOrder="58">
<Company>南方航空</Company>
<AirlineCode>CZ9906</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:00</StartTime>
<ArriveTime>19:25</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime60" msdata:rowOrder="59">
<Company>東方航空</Company>
<AirlineCode>MU3929</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:20</StartTime>
<ArriveTime>19:35</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime61" msdata:rowOrder="60">
<Company>東方航空</Company>
<AirlineCode>MU3929</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:20</StartTime>
<ArriveTime>19:35</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime62" msdata:rowOrder="61">
<Company>吉祥航空</Company>
<AirlineCode>HO1253</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:20</StartTime>
<ArriveTime>19:35</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime63" msdata:rowOrder="62">
<Company>吉祥航空</Company>
<AirlineCode>HO1253</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:20</StartTime>
<ArriveTime>19:35</ArriveTime>
<Mode>321</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime64" msdata:rowOrder="63">
<Company>東方航空</Company>
<AirlineCode>MU5181</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:40</StartTime>
<ArriveTime>19:50</ArriveTime>
<Mode>76A</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime65" msdata:rowOrder="64">
<Company>南方航空</Company>
<AirlineCode>CZ9924</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:40</StartTime>
<ArriveTime>19:50</ArriveTime>
<Mode>76A</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime66" msdata:rowOrder="65">
<Company>深圳航空</Company>
<AirlineCode>ZH1522</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:55</StartTime>
<ArriveTime>20:20</ArriveTime>
<Mode>773</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime67" msdata:rowOrder="66">
<Company>中國國航</Company>
<AirlineCode>CA1522</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>17:55</StartTime>
<ArriveTime>20:20</ArriveTime>
<Mode>773</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime68" msdata:rowOrder="67">
<Company>東方航空</Company>
<AirlineCode>MU5121</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>18:00</StartTime>
<ArriveTime>20:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime69" msdata:rowOrder="68">
<Company>南方航空</Company>
<AirlineCode>CZ9908</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>18:00</StartTime>
<ArriveTime>20:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime70" msdata:rowOrder="69">
<Company>東方航空</Company>
<AirlineCode>MU3844</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京南苑機場</ArriveDrome>
<StartTime>18:30</StartTime>
<ArriveTime>20:35</ArriveTime>
<Mode>737</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime71" msdata:rowOrder="70">
<Company>中國聯航</Company>
<AirlineCode>KN5956</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京南苑機場</ArriveDrome>
<StartTime>18:30</StartTime>
<ArriveTime>20:35</ArriveTime>
<Mode>737</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime72" msdata:rowOrder="71">
<Company>深圳航空</Company>
<AirlineCode>ZH1516</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>18:55</StartTime>
<ArriveTime>21:20</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime73" msdata:rowOrder="72">
<Company>中國國航</Company>
<AirlineCode>CA1516</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>18:55</StartTime>
<ArriveTime>21:20</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime74" msdata:rowOrder="73">
<Company>東方航空</Company>
<AirlineCode>MU5123</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>19:00</StartTime>
<ArriveTime>21:25</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime75" msdata:rowOrder="74">
<Company>南方航空</Company>
<AirlineCode>CZ9910</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>19:00</StartTime>
<ArriveTime>21:25</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime76" msdata:rowOrder="75">
<Company>深圳航空</Company>
<AirlineCode>ZH1550</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>19:55</StartTime>
<ArriveTime>22:15</ArriveTime>
<Mode>773</Mode>
<AirlineStop>0</AirlineStop>
<Week>145日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime77" msdata:rowOrder="76">
<Company>中國國航</Company>
<AirlineCode>CA1550</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>19:55</StartTime>
<ArriveTime>22:15</ArriveTime>
<Mode>773</Mode>
<AirlineStop>0</AirlineStop>
<Week>145日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime78" msdata:rowOrder="77">
<Company>東方航空</Company>
<AirlineCode>MU5125</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:00</StartTime>
<ArriveTime>22:25</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime79" msdata:rowOrder="78">
<Company>南方航空</Company>
<AirlineCode>CZ9912</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:00</StartTime>
<ArriveTime>22:25</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime80" msdata:rowOrder="79">
<Company>東方航空</Company>
<AirlineCode>MU5199</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:30</StartTime>
<ArriveTime>23:00</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime81" msdata:rowOrder="80">
<Company>南方航空</Company>
<AirlineCode>CZ9926</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:30</StartTime>
<ArriveTime>23:00</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime82" msdata:rowOrder="81">
<Company>海南航空</Company>
<AirlineCode>HU7602</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:40</StartTime>
<ArriveTime>23:10</ArriveTime>
<Mode>738</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime83" msdata:rowOrder="82">
<Company>深圳航空</Company>
<AirlineCode>ZH1856</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:55</StartTime>
<ArriveTime>23:15</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>1246</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime84" msdata:rowOrder="83">
<Company>深圳航空</Company>
<AirlineCode>ZH4912</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:55</StartTime>
<ArriveTime>23:05</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>2456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime85" msdata:rowOrder="84">
<Company>中國國航</Company>
<AirlineCode>CA178</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:55</StartTime>
<ArriveTime>23:05</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>2456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime86" msdata:rowOrder="85">
<Company>中國國航</Company>
<AirlineCode>CA1856</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>20:55</StartTime>
<ArriveTime>23:15</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>1246</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime87" msdata:rowOrder="86">
<Company>東方航空</Company>
<AirlineCode>MU5127</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:00</StartTime>
<ArriveTime>23:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>345日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime88" msdata:rowOrder="87">
<Company>南方航空</Company>
<AirlineCode>CZ9914</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:00</StartTime>
<ArriveTime>23:20</ArriveTime>
<Mode>333</Mode>
<AirlineStop>0</AirlineStop>
<Week>12345</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime89" msdata:rowOrder="88">
<Company>東方航空</Company>
<AirlineCode>MU5186</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:10</StartTime>
<ArriveTime>23:40</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>246日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime90" msdata:rowOrder="89">
<Company>南方航空</Company>
<AirlineCode>CZ9886</AirlineCode>
<StartDrome>上海浦東國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:10</StartTime>
<ArriveTime>23:40</ArriveTime>
<Mode>JET</Mode>
<AirlineStop>0</AirlineStop>
<Week>246日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime91" msdata:rowOrder="90">
<Company>東方航空</Company>
<AirlineCode>MU9107</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:30</StartTime>
<ArriveTime>23:45</ArriveTime>
<Mode>738</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime92" msdata:rowOrder="91">
<Company>上海航空</Company>
<AirlineCode>FM9107</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:30</StartTime>
<ArriveTime>23:45</ArriveTime>
<Mode>738</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime93" msdata:rowOrder="92">
<Company>東方航空</Company>
<AirlineCode>MU3927</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:50</StartTime>
<ArriveTime>00:20</ArriveTime>
<Mode>320</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime94" msdata:rowOrder="93">
<Company>吉祥航空</Company>
<AirlineCode>HO1251</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:50</StartTime>
<ArriveTime>00:20</ArriveTime>
<Mode>320</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime95" msdata:rowOrder="94">
<Company>中國國航</Company>
<AirlineCode>CA5902</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:50</StartTime>
<ArriveTime>00:20</ArriveTime>
<Mode>320</Mode>
<AirlineStop>0</AirlineStop>
<Week>123456日</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime96" msdata:rowOrder="95">
<Company>深圳航空</Company>
<AirlineCode>ZH1886</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:55</StartTime>
<ArriveTime>00:20</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>1234</Week>
</AirlinesTime>
<AirlinesTime diffgr:id="AirlinesTime97" msdata:rowOrder="96">
<Company>中國國航</Company>
<AirlineCode>CA1886</AirlineCode>
<StartDrome>上海虹橋國際機場</StartDrome>
<ArriveDrome>北京首都國際機場</ArriveDrome>
<StartTime>21:55</StartTime>
<ArriveTime>00:20</ArriveTime>
<Mode>330</Mode>
<AirlineStop>0</AirlineStop>
<Week>1234</Week>
</AirlinesTime>
</Airlines>
</diffgr:diffgram>
</DataSet>

  創建demo.asmx 如下:

/// <summary>
    /// demo 的摘要說明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允許使用 ASP.NET AJAX 從腳本中調用此 Web 服務,請取消對下行的注釋。
    // [System.Web.Script.Services.ScriptService]
    public class demo : System.Web.Services.WebService
    {


          // WEB 服務示例
          // HelloWorld() 示例服務返回字符串 Hello World
          // 若要生成,請取消注釋下列行,然後保存並生成項目
          // 若要測試此 Web 服務,請按 F5 鍵
          /// <summary>
          /// 字符串型
          /// </summary>
          /// <returns>Hello World</returns>
          [WebMethod(Description = "字符串型")]        
          public string HelloWorld()
          {
           return "Hello World";
          }
          /// <summary>
          /// 整型
          /// </summary>
          /// <returns>Int</returns>
          [WebMethod(Description = "整型")]
          public int GetInt()
          {
           return 1234;
          }
  
          /// <summary>
          /// 布爾型
          /// </summary>
          /// <returns>Bool</returns>
          [WebMethod(Description = "布爾型")]
          public bool GetBool()
          {
           return true;
          }
          /// <summary>
          /// 返回實體類
          /// 必須是已序列化的類
          /// </summary>
          /// <returns>學生類</returns>
          [WebMethod(Description = "學生類")]
          public Student GetStudent()
          {
           Student stu = new Student();
           stu.Name = "張三";
           stu.Age = 25;
           stu.Sex = true;
           return stu;
          }
          /// <summary>
          /// 返回DataSet數據類型
          /// </summary>
          /// <returns>DataSet</returns>
          [WebMethod(Description = "DataSet.")]
          public DataSet GetDataSet()
          {
           DataSet ds = new DataSet();
           return ds;
          }
          /// <summary>
          /// 
          /// </summary>
          /// <param name="key"></param>
          /// <returns></returns>
          [WebMethod(Description = "輸入字符串 ,返回DataSet數據類型")]
          public DataSet GetDataTable(string key)
          {
              DataSet rd = new DataSet();
              try
              {
                  DataTable dt = new DataTable();
                  dt.Columns.Add("id", typeof(int));
                  dt.Columns.Add("name", typeof(string));
                  dt.Columns.Add("code", typeof(string));
                  dt.Rows.Add(1, "geovindu", "0091");
                  dt.Rows.Add(2, "du", "0094");
                  dt.Rows.Add(3, "geovin", "0095");
                  dt.Rows.Add(4, "sibodu", "0093");
                  dt.Rows.Add(5, "ginhongzhao", "du");
                  //var query = from p in dt.AsEnumerable()
                  //            where p.Field<string>("code") == key
                  //            select new
                  //            {
                  //                name = p.Field<string>("name"),
                  //                age = p.Field<int>("age")
                  //            };
                  IEnumerable<DataRow> query1 = from contact in dt.AsEnumerable()
                                                where contact.Field<string>("name") == key
                                                select contact;

                  IEnumerable<DataRow> query2 = from contact in dt.AsEnumerable()
                                                where contact.Field<string>("code") == key
                                                select contact;

                  IEnumerable<DataRow> query3 = dt.Select("name ='"+key+"' or  code = '"+key+"'");

                  DataTable contacts1;
                  DataTable contacts2;
                  DataTable contacts3;

                  if (query1.Count() > 0)
                  {
                      contacts1 = query1.CopyToDataTable();
                      rd = SplitRows(contacts1);
                  }
                  if (query2.Count()>0)
                  {
                      contacts2 = query2.CopyToDataTable();
                      rd.Tables.Add(contacts2);
                  }

                  if (query3.Count() > 0)
                  {
                      contacts3 = query3.CopyToDataTable();
                      rd.Tables.Add(contacts3);
                  }


              }
              catch (Exception ex)
              {
                  ex.Message.ToString();
              }
              return rd;
          }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
          private DataSet SplitRows(DataTable source)
          {

              DataSet ds = new DataSet();

              foreach (DataRow r in source.Rows)
              {
                  DataTable copy = source.Clone();
                  copy.LoadDataRow(r.ItemArray, true);
                  ds.Tables.Add(copy);
              }

              return ds;

          }

         }
         #region 定義可序列化類
         /*
          * 為避免Framework1.1中返回實體類報錯“請求格式無法識別。”
          * 要在Web.Config文件中<system.web>添加以下內容:
          * <webServices>
           <protocols>
           <add name="HttpPost" />
           <add name="HttpGet" />
           </protocols>
          </webServices>
          */
         //指示下面的類可序列化
         /// <summary>
         /// 學生基本信息類
         /// </summary>
         [Serializable]
         public class Student 
         {
          /// <summary>
          /// 構造函數
          /// </summary>
          public Student()
          {
          }
          private string name;
          /// <summary>
          /// 姓名
          /// </summary>
          public string Name
          {
           get
           {
            return name;
           }
           set
           {
            name=value;
           }
          }
          private bool sex;
          /// <summary>
          /// 性別--布爾型變量真為女,假為男
          /// </summary>
          public bool Sex
          {
           get
           {
            return sex;
           }
           set
           {
            sex=value;
           }
          }
          private int age;
          /// <summary>
          /// 年齡
          /// </summary>
          public int Age
          {
           get
           {
            return age;
           }
           set
           {
            age=value;
           }
          }
         }
 #endregion

  測試:

                //http://localhost:25608/demo.asmx
                string url = "http://localhost:25608/demo.asmx";
                object[] args = new object[1];
                args[0]="du";
                object result = WSHelper.InvokeWebService(url, "GetDataTable", args);
                 DataSet ds = (DataSet)result;
                this.GridView1.DataSource = ds.Tables[2];
                this.GridView1.DataBind();
            }
            catch (Exception ex)
            {
               Response.Write(ex.Message.ToString());

  

 /// <summary>
    /// 取得所有Method Name
     /// </summary>
     public class MethodInfo
     {
         /// <summary>
         /// 主method 名稱
         /// </summary>
         public string MethodName { get; set; }
  
         /// <summary>
         /// 在WSDL 中 InputMessage的名稱 通常為 [MethodName]SoapIn
         /// </summary>
         public string InputMessageName { get; set; }
  
         /// <summary>
         /// 在WSDL 中 OutputMessage的名稱 通常為 [MethodName]SoapOut
         /// </summary>
         public string OutputMessageName { get; set; }
  
         /// <summary>
         /// 輸入的參數們 Key名稱 , Value為型別
         /// </summary>
         public Dictionary<string,string> InputParameters { get; set; }
  
         /// <summary>
         /// 輸出的參數們 Key名稱 , Value為型別
         /// </summary>
         public Dictionary<string, string> OutParameters { get; set; }
         public string Desc { get; set; }
  
         public MethodInfo()
         {
             InputParameters=new Dictionary<string, string>();
             OutParameters=new Dictionary<string, string>();
         }

         /// <summary>
         /// 透過網址取得資料後 並且讀為 GeServiceDescriptionFromServicePath
         /// </summary>
         /// <param name="servicePath"></param>
         /// <returns></returns>
         private ServiceDescription GeServiceDescriptionFromServicePath(string servicePath)
         {
             if (!servicePath.ToLower().Contains("?wsdl"))
             {
                 servicePath = servicePath + "?wsdl";
             }

             var wc = new WebClient();
             wc.Encoding = UTF8Encoding.UTF8;
             byte[] byteArray = Encoding.UTF8.GetBytes(wc.DownloadString(servicePath));
             var stream = new MemoryStream(byteArray);
             return ServiceDescription.Read(stream);
         }


         /// <summary>
         /// 取得 Parameters 
         /// </summary>
         /// <param name="serviceDescription"></param>
         /// <param name="messagePartName"></param>
         /// <returns></returns>
         private static Dictionary<string, string> GetParameters(ServiceDescription serviceDescription, string messagePartName)
         {
             var types = serviceDescription.Types;
             var xmlSchema = types.Schemas[0];
             return (from schemaElement in xmlSchema.Items.OfType<XmlSchemaElement>() where schemaElement.Name == messagePartName select schemaElement.SchemaType).OfType<XmlSchemaComplexType>().Select(complexType => complexType.Particle).OfType<XmlSchemaSequence>().SelectMany(sequence => sequence.Items.Cast<XmlSchemaElement>()).ToDictionary(childElement => childElement.Name, childElement => childElement.SchemaTypeName.Name);
         }

         /// <summary>
         /// 取得所有的Method Details
         /// </summary>
         /// <param name="serviceDescription"></param>
         /// <returns></returns>
         public MethodInfo[] GetMethodInfos(ServiceDescription serviceDescription)
         {
             var res = new List<MethodInfo>();

             foreach (PortType portType in serviceDescription.PortTypes)
             {
                 foreach (Operation operation in portType.Operations)
                 {

                     var me = new MethodInfo();
                     me.MethodName = operation.Name;
                     me.InputMessageName = operation.Messages.Input.Message.Name;
                     me.OutputMessageName = operation.Messages.Output.Message.Name;

                     //注1
                     me.InputParameters = GetParameters(serviceDescription, serviceDescription.Messages[me.InputMessageName].Parts[0].Element.Name);
                     me.OutParameters = GetParameters(serviceDescription, serviceDescription.Messages[me.OutputMessageName].Parts[0].Element.Name);

                     if (operation.DocumentationElement != null)
                         me.Desc = operation.DocumentationElement.InnerText;

                     res.Add(me);
                 }
             }


             return res.ToArray();
         }

     }

  測試:

 txtWebServicePath.Text = "http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx";
            var serviceDesc = GeServiceDescriptionFromServicePath(txtWebServicePath.Text);
            //取得所有Method Name .
            var allMethodNames = GetAllMethodsName(serviceDesc).Distinct();
            ltlResult.Text = "";
            ltlResult.Text += "<ul>";
            foreach (var s in allMethodNames)
            {
                ltlResult.Text += "<li>" + s + "</li>";
            }
            ltlResult.Text += "</ul>";

  

 

    /// <summary>
    /// 
    /// </summary>
    public class WSHelper
    {
        /// < summary> 
        /// 動態調用web服務 
        /// < /summary> 
        /// < param name="url">WSDL服務地址< /param> 
        /// < param name="methodname">方法名< /param> 
        /// < param name="args">參數< /param> 
        /// < returns>< /returns> 
        public static object InvokeWebService(string url, string methodname, object[] args) 
        { 
            return WSHelper.InvokeWebService(url, null, methodname, args); 
        } 
        /// < summary> 
        /// 動態調用web服務 
        /// < /summary> 
        /// < param name="url">WSDL服務地址< /param> 
        /// < param name="classname">類名< /param> 
        /// < param name="methodname">方法名< /param> 
        /// < param name="args">參數< /param> 
        /// < returns>< /returns> 
        public static object InvokeWebService(string url, string classname, string methodname, object[] args) 
        { 
                string @namespace = "EnterpriseServerBase.WebService.DynamicWebCalling"; 
                if ((classname == null) || (classname == "")) 
                { 
                classname = WSHelper.GetWsClassName(url); 
                } 
                try 
                { //獲取WSDL 
                WebClient wc = new WebClient(); 
                Stream stream = wc.OpenRead(url + "?WSDL"); 
                ServiceDescription sd = ServiceDescription.Read(stream); 
                ServiceDescriptionImporter sdi = new ServiceDescriptionImporter(); 
                sdi.AddServiceDescription(sd, "", ""); 
                CodeNamespace cn = new CodeNamespace(@namespace); 
                //生成客戶端代理類代碼 
                CodeCompileUnit ccu = new CodeCompileUnit(); 
                ccu.Namespaces.Add(cn); 
                sdi.Import(cn, ccu); 
                CSharpCodeProvider icc = new CSharpCodeProvider(); 
                //設定編譯參數 
                CompilerParameters cplist = new CompilerParameters(); 
                cplist.GenerateExecutable = false; 
                cplist.GenerateInMemory = true; 
                cplist.ReferencedAssemblies.Add("System.dll"); 
                cplist.ReferencedAssemblies.Add("System.XML.dll"); 
                cplist.ReferencedAssemblies.Add("System.Web.Services.dll"); 
                cplist.ReferencedAssemblies.Add("System.Data.dll"); 
                //編譯代理類 
                CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu); 
                if (true == cr.Errors.HasErrors) 
                { 
                System.Text.StringBuilder sb = new System.Text.StringBuilder(); 
                foreach (System.CodeDom.Compiler.CompilerError ce in cr.Errors) 
                { 
                sb.Append(ce.ToString()); 
                sb.Append(System.Environment.NewLine); 
                } 
                throw new Exception(sb.ToString()); 
                } 
                //生成代理實例,並調用方法 
                System.Reflection.Assembly assembly = cr.CompiledAssembly; 
                Type t = assembly.GetType(@namespace + "." + classname, true, true); 
                object obj = Activator.CreateInstance(t); 
                System.Reflection.MethodInfo mi = t.GetMethod(methodname); 
                return mi.Invoke(obj, args); 
                // PropertyInfo propertyInfo = type.GetProperty(propertyname); 
                //return propertyInfo.GetValue(obj, null); 
                } 
                catch (Exception ex) 
                { 
                    throw new Exception(ex.InnerException.Message, new Exception(ex.InnerException.StackTrace)); 
                } 
        } 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="wsUrl"></param>
        /// <returns></returns>
        private static string GetWsClassName(string wsUrl) 
        { 
            string[] parts = wsUrl.Split('/'); 
            string[] pps = parts[parts.Length - 1].Split('.'); 
            return pps[0]; 
        } 

        } 

  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved