码迷,mamicode.com
首页 > Web开发 > 详细

Web Service Demo

时间:2019-11-04 17:27:32      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:inf   add   sicp   file   uri   dem   div   sys   项目   

有了Web Service的一些基础,具体如何实现,通过亲自写一个Demo来理解一下。

1.创建一个空的Web项目

技术图片

 

 2.在Web项目下ADD一个Web Service

技术图片

 

3.在Web service中写个简答的方法

技术图片

技术图片
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace Demo
{
    /// <summary>
    /// WebService Demo
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]//WebService别名
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Myservice : System.Web.Services.WebService
    {
        [WebMethod]//特性
        public int add(int a, int b)
        {
            return a * b;
        }
    }
}
Myservice.asmx

4.项目完成,开始发布。

技术图片

 

 4.1 Publish method选择File System 

    

 

Web Service Demo

标签:inf   add   sicp   file   uri   dem   div   sys   项目   

原文地址:https://www.cnblogs.com/cdjbolg/p/11792924.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!