ForEvErNoMe 发表于 2013-1-1 21:55:15

Web Services 应用开发学习笔记(五):创建WebService的简单例子

<div id="cnblogs_post_body">如何创建一个小型的WebService呢?下面将会一步步介绍这一操作!

1.创建一个空的WebSource网站,添加一个AddService.asmx文件。
http://pic002.cnblogs.com/images/2012/349636/2012090201324915.jpg

2.向AddService.asmx添加计算两数之和的方法。
<div class="cnblogs_code" >http://images.cnblogs.com/OutliningIndicators/ContractedBlock.gifhttp://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gifView Code <div id="cnblogs_code_open_bcd7d337-e246-4ca0-9b01-f5638ab9d9e4" class="cnblogs_code_hide">using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;/// <summary>///AddService 返回两数之和服务/// </summary>"http://tempuri.org/")]= WsiProfiles.BasicProfile1_1)]//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 // public class AddService : System.Web.Services.WebService {    public AddService () {      //如果使用设计的组件,请取消注释以下行         //InitializeComponent();     }        public string HelloWorld() {      return "Hello World";    }    = "返回两数之和")]    public int AddResult(int a,int b)    {      return a + b;    }}
页: [1]
查看完整版本: Web Services 应用开发学习笔记(五):创建WebService的简单例子