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

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.csdn.net/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));

 

 

posted on 2013-01-30 17:27  望风的日子  阅读(503)  评论(0编辑  收藏  举报