添加Web服务引用,服务引用,WCF服务开发

本文介绍了Visual Studio 2008中添加WebService引用和WCF服务引用的方法,并提供了WCF服务开发与调用的示例,包括通过Ajax异步调用WCF服务的具体实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://social.microsoft.com/Forums/zh-CN/xmlwebserviceszhchs/thread/808d870b-49f1-47ac-b105-4beb580bcec6

(1)VS2005里提供的Add Web Reference(添加Web服务引用)的功能主要是添加Web Service引用。
(2)VS2008保留了Add Web Reference(添加Web服务引用)也是为了版本向前兼容。目前很多项目还是基于.NET Framework 2.0。
(3)VS2008在升级以后为了对.NET Framework 3.0 或 3.5版本上WCF Service Library的支持。增加了Add Service Reference(添加服务引用)功能。Framework3.0 或 3.5 时可用。

你如果调用WebService则添加web引用
如果调用WCF则添加服务引用

2:WCF服务开发与调用的完整示例

http://blog.youkuaiyun.com/fxhflower/article/details/7274925

3:

Ajax异步调用WCF服务

http://blog.163.com/lc_chenlong/blog/static/18043155720119155635787/

ajax调用WCFService.Clien 为AJAXt掉用WCF客户端 

function fn1() {
            $.ajax({
                url: "http://localhost/wcfservice2/Service1.svc/Add",
                type: "POST",
                contentType: "text/json",

                data: '{"x1":1,"x2":2}',
                dataType: "json",
                success: function (returnValue) {
                    alert(returnValue);
                }
            });

后台调用需要添加服务引用,和配置config的终结点
 <system.serviceModel>
    
    <client>
      <endpoint address="http://172.16.0.145/wcfservice2/Service1.svc/basic"
        binding="basicHttpBinding" contract="ServiceReference1.IContract" />
      
      <endpoint address="http://172.16.4.60/wcf/Service1.svc/basic"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IContract1"
        contract="ServiceReference2.IContract" name="BasicHttpBinding_IContract" />
    </client>
  </system.serviceModel>

调用
ServiceReference2.ContractClient client = new ServiceReference2.ContractClient();

            Response.Write(client.Add(1,2));

 

 

转载于:https://www.cnblogs.com/wangfengderizi/archive/2013/01/30/2883413.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值