RSS
热门关键字:  cms  下载  模版  开源  dedecms
当前位置 :| 主页>站长学院>服务器>

在.NET中使用Web服务

来源:互连网 作者:佚名 时间:2005-10-24 点击:

最近因为要开发项目组里的Web模块,开始学习.NET平台,发现在.NET平台下使用Web服务还是很简单的。
下面举个在.NET平台下创建Web服务的简单例子。首先用Visul Studio .Net创建一个C# 项目Asp.Net Web服务程序,源代码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;


namespace author
{
     /// <summary>
     /// Service1 的摘要说明。
     /// </summary>
     public class Service1 : System.Web.Services.WebService
    {
         public Service1()
        {
              //CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
              InitializeComponent();
        }


       #region 组件设计器生成的代码
  
      //Web 服务设计器所必需的
      private IContainer components = null;
    
      /// <summary>
      /// 设计器支持所需的方法 - 不要使用代码编辑器修改
      /// 此方法的内容。
      /// </summary>
      private void InitializeComponent()
     {
     }


     /// <summary>
     /// 清理所有正在使用的资源。
     /// </summary>
     protected override void Dispose( bool disposing )
    {
           if(disposing && components != null)
          {
                components.Dispose();
          }
          base.Dispose(disposing);  
    }
  
    #endregion


    // WEB 服务示例
    // HelloWorld() 示例服务返回字符串 Hello World
    // 若要生成,请取消注释下列行,然后保存并生成项目
    // 若要测试此 Web 服务,请按 F5 键


   // [WebMethod]
   // public string HelloWorld()
   //{
   //      return "Hello World";
   /

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
栏目列表