在 Visual Studio 2012 中创建 ASP.Net Web Service
来源:互联网 发布:r230清零软件图解 编辑:程序博客网 时间:2024/06/05 16:19
实践检验,Visual Studio 2013页是类似
在 Visual Studio 2012 中创建 ASP.Net Web Service,步骤非常简单。如下:
第一步:创建一个“ASP.Net Empty Web Application”项目
创建一个“ASP.Net Empty Web Application”项目。你会看到一个进度条,显示 Visual Studio 2012 正在创建这个空的 ASP.Net Web Application。
经历短暂的等待之后,一个空的 ASP.Net Web Application 就建好了,它仅包含一个站点配制文件(Web.config),其余的什么也没有。
第二步:在项目中添加“Web Service”新项目
在 Visual Studio 2012 的 Solution Explorer 中,选中当前的这个 project,添加新项目(右键菜单:Add --> New Item),选择“Web Service”这种类型:
第三步:编码、运行
添加完Web Service这种 new item 之后,Visual Studio 已经替我们写了个示范的Web方法了:
直接按快捷键 F5 就可以看到结果:
点击 HelloWorld 这个链接:
点击页面上的 Invoke 按钮:
然后我们改写这段代码,添加我们自己的方法进去:
- namespace WebApplication1
- {
- using System.Web.Services;
- /// <summary>
- /// Summary description for WebService1
- /// </summary>
- [WebService(Namespace = "http://tempuri.org/")]
- public class WebService1 : System.Web.Services.WebService
- {
- [WebMethod]
- public string HelloWorld()
- {
- return "Hello World";
- }
- [WebMethod]
- public int Add(int x, int y)
- {
- return x + y;
- }
- }
- }
运行:
点击 Add 链接,调用我们刚刚自己添加的 Add 函数:
点击页面上的 Invoke 按钮,得到以 XML 格式返回的执行结果:
+
整个过程非常简单、直观。
参考:http://blog.csdn.net/yapingxin/article/details/7993989
- 在 Visual Studio 2012 中创建 ASP.Net Web Service
- 在 Visual Studio 2012 中创建 ASP.Net Web Service
- 在 Visual Studio 2012 中创建 ASP.Net Web Service
- 在 Visual Studio 2010 中创建 ASP.Net Web Service
- 在 Visual Studio 2010 中创建 ASP.Net Web Service
- 在 Visual Studio 2010 中创建 ASP.Net Web Service
- 在 Visual Studio 2010 中创建 ASP.Net Web Service
- (转)在 Visual Studio 2010 中创建 ASP.Net Web Service
- 演练:在 Visual Web Developer 中创建和使用 ASP.NET Web 服务------Web Service
- 在 Visual Studio 2013 中创建 ASP.NET Web 项目(1):概述 - 创建 Web 应用程序项目
- Visual studio 2012 创建web service
- 为何我不能在我的VISUAL STUDIO .NET中创建ASP.NET项目(程序)
- 在Visual Studio 2005 Web Application Project中使用ASP.NET AJAX
- Visual Studio 2012打开项目 提示ASP.NET 4.0未在web服务器上注册
- Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer Visual Studio 2010 O
- 如何使用 Visual Studio .NET 和 Office xp 创建和部署 XML Web service
- ASP.NET 5系列教程 (五):在Visual Studio 2015中使用Grunt、Bower开发Web程序
- ASP.NET 5系列教程 (五):在Visual Studio 2015中使用Grunt、Bower开发Web程序
- 最大的子序列和问题
- Android 获取assets绝对路径
- GDB使用介绍
- 二叉树宽度高度和判断是否相等
- UVA253 - Cube painting
- 在 Visual Studio 2012 中创建 ASP.Net Web Service
- 在Fragment中使用Loader机制介绍
- poj 2431 Expedition
- Python中*args 和**kwargs的用法
- 剑指offer 面试题6 重建二叉树
- Angular.js的使用原因
- Android动态加载oat文件总结一
- 设置Eclipse编码方式
- 交换x,y的三种方式