在WindowsForm程序中添加服务引用和Web引用对比

为了验证书上有关Visual Studio 2010添加服务引用和Web引用的区别,进行实验。

一、建立一个Web服务程序项目
新建项目,选择ASP.NET空Web应用程序,在其中添加Web服务,然后发布到IIS,路径为http://localhost/hello/hello.asmx,服务主要通过HelloWorld()方法输出字符串“Hello World”,内容如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace Hello
{
    /// <summary>
    /// Hello 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class Hello : System.Web.Services.WebService
    {

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

二、建立测试程序

窗体应用程序,在项目中选择添加服务引用,选择高级,添加Web引用来使用,引用后可以看到在Service References文件夹下出现的ServiceReferrence1中有:configuration.svcinfo,configuration91.svcinfo,hello.disco,hello.wsdl,Reference.cs,Reference.svcmap,共六个文件,或者直接添加服务引用。要使用的泪和方法在下图:

在Web项目和Web网站解决方案引用时可以选择添加Web引用还是服务引用。

1.添加Web引用,选择命名空间为localhost,在App_WebReferences文件夹下出现引用信息,localhost文件夹下有如下文件:Hello.disco,Hello.discomap,Hello.wsdl。

2.添加服务引用,命名空间为local1,local1文件夹中有以下文件:configuration.svcinfo,configuration91.svcinfo,hello.disco,Hello.wsdl,Reference.svcmap。

效果如下

 
 
 
 
 

(转)添加服务引用和添加Web引用对比的更多相关文章

  1. 添加web引用和添加服务引用有什么区别?

    添加web引用和添加服务引用有什么区别,Add Service References 和 Add Web References 有啥区别?参考 http://social.microsoft.com/ ...

  2. (转)2.4.1 基础知识--添加服务引用与Web引用的区别

    <Web服务开发学习实录>第2章构建ASP.NET Web服务,本章我们将学习创建Web服务的各种方法,并重点对使用Visual Studio创建ASP.NET Web服务和修改Web服务 ...

  3. 关于WCF的引用,添加服务和添加web服务的区别

    原文:关于WCF的引用,添加服务和添加web服务的区别 本章内容主要是根据我做的实验来阐述这2种添加服务针对WCF的不同之处,我们按照示例一步一步来看. 如下是工程的结构: 该WCF服务是通过控制台程 ...

  4. 添加服务引用和添加Web引用对比

    原文:添加服务引用和添加Web引用对比 在WindowsForm程序中添加服务引用和Web引用对比 为了验证书上有关Visual Studio 2010添加服务引用和Web引用的区别,进行实验. 一. ...

  5. VS中,添加完Web引用(WebServer引用/Web服务引用),写代码时引用不到

    VS中,添加完Web引用(WebServer引用/Web服务引用),写代码时引用不到 添加完之后要等一会儿 等一会儿 等一会儿 就有了

  6. .net 添加web引用和添加服务引用有什么区别?

    添加web引用和添加服务引用有什么区别, Add Service References 和 Add Web References 有啥区别? 参考 http://social.microsoft.co ...

  7. WebService-.Net:添加web引用和添加服务引用有什么区别?

    ylbtech-WebService-.Net:添加web引用和添加服务引用有什么区别? 1.返回顶部 1. 添加web引用和添加服务引用有什么区别,Add Service References 和 ...

  8. [问题]通过IIS宿主发布WCF服务,客户端添加服务引用出错的解决办法

    环境配置:Web服务器:Windows Server 2008,iis7.5,.net4.0客户端:XPsp3 vs2010 sp1 问题描述:1.确定WCF服务访问地址  http://servic ...

  9. Xamarin.Forms项目无法添加服务引用

    Xamarin.Forms项目无法添加服务引用 创建的Xamarin.Forms项目中,右击“引用”选项,在弹出的菜单中没有“添加服务引用”命令.这是由于该项目是支持Windows Phone 8.1 ...

随机推荐

  1. (转)回车 执行button点击

    功能说明:当我们注册或者执行搜索时,输入内容后,不用单击按钮来执行按钮单击事件,而直接通过回车来执行按钮单击事件.只要在text框中onkeydown事件中加入执行按钮的onclick事件就OK了 代 ...

  2. (转)SQL中的ISNULL函数介绍

    SQL中有多种多样的函数,下面将为您介绍SQL中的ISNULL函数,包括其语法.注释.返回类型等,供您参考,希望对您学习SQL能够有所帮助. ISNULL 使用指定的替换值替换 NULL. 语法ISN ...

  3. IE9的window.showmodaldialog显示问题

    <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=&quo ...

  4. 32位PLSQL_Developer连接oracle11g_64位

    1. 请将你下载的instantclient-basic-win32-10.2.0.5 文件解压.然后复制到你的数据库安装的文件夹下的producti文件夹下,我的是: E:\app\Administ ...

  5. pch文件出现no such file or directory错误

    一般出现这种情况是由于项目直接拷贝到其他电脑上运行... clang: error: no such file or directory: '/demo2/控件代码/13/Recorder/Recor ...

  6. C#Dictionary 实例

    Dictionary<int, string> dc = new Dictionary<int, string>(); dc.Add(, "看了"); dc ...

  7. angularjs使用ng-messages-include实例

    <!DOCTYPE html> <html lang="zh-CN" ng-app="app"> <head> <me ...

  8. effectivec++条款18,让接口容易被正确使用,不宜被吴勇

    test* create_test(); shared_ptr<test> create_test();//下面的接口比上面的接口要好 auto_ptr<test> creat ...

  9. 树形dp入门

    poj2057 某公司的上下级关系是一颗树状结构,每个人不能与他的上司同时出现,每个人有一个值,求最大值. 这个题需要注意的是如果不保存状态会超时,这似乎也是大部分dp应该注意的事情啊 #includ ...

  10. python 登陆一个网站

    今天想用python写一个登陆的脚本,搜了一下,网上挺多的,看了一些后写了个登陆虎扑论坛的脚本. 原理: 只要在发送http请求时,带上含有正常登陆的cookie就可以了. 1.首先我们要先了解coo ...