WebService还某种程度上有点象COM,.......

解决方案 »

  1.   

    Web services有这样两个用途:将多个系统整合到一起,以及将功能函数作为组件提供给远程调用。
      

  2.   

    WebService用来作中间层的。可以远程调用。例如你在中国可以调用美国的web service。
      

  3.   

    类似dll,类似函数库,只不过是分布式的,在远程计算机上执行过程,返回到本地计算机。
      

  4.   

    asp.net 的结果显示为网页供人阅读,web service 的结果为xml,供调用者(一般为客户机的应用程序)查看。
      

  5.   

    有没有谁可以提供一个关于webService的使用例子,
    最简单的方法和调用!
      

  6.   

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Web;
    using System.Web.Services;
    using System.Xml;
    using System.Xml.XPath;namespace Coordinator
    {
    /// <summary>
    /// Summary description for Coordinator.
    /// </summary>
    [WebService(Namespace="http://www.linkrun.com.cn/QueryWebService/")]
    public class Coordinator : System.Web.Services.WebService
    {
    // private const string configFile = @"d:\MaterialAssembly\SubApplicationConfig.xml";
    // private System.Xml.XPath.XPathDocument doc;
    private string Popedom="0";

    public Coordinator()
    {
    InitializeComponent();
    } #region Component Designer generated code

    //Required by the Web Services Designer 
    private IContainer components = null;

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if(disposing && components != null)
    {
    components.Dispose();
    }
    base.Dispose(disposing);
    }

    #endregion [WebMethod(EnableSession=true)]
    public string Authenticate(string usercode, string password)
    {
    Operator objOpe = new Operator(usercode);
    if(objOpe.ConfirmLogin(password)==1)
    {
    Session["Popedom"] = objOpe.Popedom;
    // this.Application["Popedom"] = objOpe.Popedom;
    return objOpe.Name;
    }
    else
    {
    return "no";
    }
    }// [WebMethod]
    // public AppFunctionality[] GetFunctionalityCatalog(string token)
    // {
    // doc = new System.Xml.XPath.XPathDocument(configFile);
    //
    // XPathNavigator nav = ((IXPathNavigable)doc).CreateNavigator();
    // XPathNodeIterator iter = nav.Select("SubApplications/SubApplication");
    // AppFunctionality[] functionality = new AppFunctionality[iter.Count];
    // int i=0;
    // while(iter.MoveNext())
    // {
    // AppFunctionality f = new AppFunctionality();
    // XPathNodeIterator iterSubApp = iter.Current.SelectDescendants(XPathNodeType.Element,true);
    // while(iterSubApp.MoveNext())
    // {
    // if(iterSubApp.Current.Name=="Name")
    // f.Name = iterSubApp.Current.Value;
    // if(iterSubApp.Current.Name=="MenuText")
    // f.MenuText = iterSubApp.Current.Value;
    // if(iterSubApp.Current.Name=="TopLevelMenuText")
    // f.TopLevelMenuText = iterSubApp.Current.Value;
    // if(iterSubApp.Current.Name=="ToolbarIconUrl")
    // f.ToolbarIconUrl = iterSubApp.Current.Value;
    // if(iterSubApp.Current.Name=="TooltipText")
    // f.TooltipText = iterSubApp.Current.Value;
    // if(iterSubApp.Current.Name=="AssemblyUrl")
    // f.AssemblyUrl = iterSubApp.Current.Value;
    // if(iterSubApp.Current.Name=="TypeName")
    // f.TypeName = iterSubApp.Current.Value;
    // }
    // functionality[i] = f;
    // i++;
    // }
    // return functionality;
    // }
    /// <summary>
    ///必须与认证配合使用
    /// </summary>
    [WebMethod(EnableSession=true)]
    public AppFunctionality[] GetFunctionalityCatalog(string token)
    {
    MenuItem menuItem=new MenuItem();
    System.Data.DataSet dsMenuItem=null;
    // Popedom = this.Application["Popedom"].ToString().Trim();//用于全局
    Popedom = Session["Popedom"].ToString().Trim();//本用户         
    dsMenuItem=menuItem.Show(Popedom);
    AppFunctionality[] functionality = new AppFunctionality[dsMenuItem.Tables[0].Rows.Count];
    int i=0;
    if(dsMenuItem!=null)
    {
    foreach (System.Data.DataRow   drv in dsMenuItem.Tables[0].Rows)
    {
    AppFunctionality f = new AppFunctionality();
    f.Name = drv["Name"].ToString();
    f.MenuText = drv["MenuText"].ToString();
    f.TopLevelMenuText = drv["TopLevelMenuText"].ToString();
    f.ToolbarIconUrl = drv["ToolbarIconUrl"].ToString();
    f.TooltipText = drv["TooltipText"].ToString();
    f.AssemblyUrl = drv["AssemblyUrl"].ToString();
    f.TypeName = drv["TypeName"].ToString();
    functionality[i] = f;
    i++;
    }
    }
    return functionality;
    }
    /// <summary>
    /// GetFunctionalityCatalog重载方法
    /// </summary>
    [WebMethod(MessageName="GetFunctionalityCatalogUID")]
    public AppFunctionality[] GetFunctionalityCatalog(string UID,string PWD)
    {
    MenuItem menuItem=new MenuItem();
    System.Data.DataSet dsMenuItem=null;
    dsMenuItem=menuItem.Show(UID,PWD);
    AppFunctionality[] functionality = new AppFunctionality[dsMenuItem.Tables[0].Rows.Count];
    int i=0;
    if(dsMenuItem!=null)
    {
    foreach (System.Data.DataRow   drv in dsMenuItem.Tables[0].Rows)
    {
    AppFunctionality f = new AppFunctionality();
    f.Name = drv["Name"].ToString();
    f.MenuText = drv["MenuText"].ToString();
    f.TopLevelMenuText = drv["TopLevelMenuText"].ToString();
    f.ToolbarIconUrl = drv["ToolbarIconUrl"].ToString();
    f.TooltipText = drv["TooltipText"].ToString();
    f.AssemblyUrl = drv["AssemblyUrl"].ToString();
    f.TypeName = drv["TypeName"].ToString();
    functionality[i] = f;
    i++;
    }
    }
    return functionality;
    }
    [WebMethod]
    public string DBConnect()
    {
    return Connection.strConnection;
    } }
    }
      

  7.   

    楼上的兄弟,能简单介绍一下你的Code的含义吗?我有个巨大的疑问,我觉得这些问题都可以用普通的Class来实现,为什么要使用WebService来做呢?不知道他以什么“武艺”存在于这个世界中。
      

  8.   

    WebServices是什么?抱歉,以下是科普文章,如果你已经对WebServices十分熟悉,可以跳过此回复,以免耽误时间。WebServices从字面上的解释是Web服务。其主要的功能是通过Web服务器提供基于XML标准词汇的数据通讯。简单的说法:就是软件间通讯方式之一。你可以使用套接字通讯,也可以使用管道通讯,还可以使用电子邮件通讯,而WebServices就是诸多通讯手段中的一种。为什么要使用WebServices?
    一、他可以过防火墙。当然你可以说任何通讯方式都可以过防火墙,不过都没有他简便。
    二、成熟的服务器端支持。WebServices的宿主主机是Web服务器,一般来说无论是IIS或者Apache都经过广泛的使用证明是可靠的,这显然好过你自己编写另一个服务器。
    三、易于解析。WebServices使用XML格式及标准词汇表,所以它是自解析格式,对于任意WebServices接口都可以容易的进行软件集成。
    四、标准化。错误的看法:
    一、WebServices与CORBA形成竞争关系。WebServices是无状态连接,我更喜欢用WebServices替换我的socket部分。与CORBA形成竞争的是Remoting和COM+,WebServices并非是一种纯粹的远程代理。
    二、WebServices是未来最重要的终结技术。所有WebServices能做到的事情我用电子邮件一样做到,而且是异步通讯,WebServices终结了谁?WebServices只是诸多通讯技术中的一种,在某些应用上占有一些先天的优势,仅此而已。