ajax调用WCF服务

ajax跨域调用wcf实例 立即下载

来自:http://blog.youkuaiyun.com/zx13525079024/article/details/7358223

关于AJAX调用WCF服务分为跨域和不跨域两种方式,今天咱们先介绍下不跨域下的调用方法。DEMO是在VS2008写的.

经过测试与研究,发现AJAX调用WCF服务必须满足以下条件

1.wcf的通讯方式必须使用webHttpBinding

2.必须设置<endpointBehaviors>节点的值

3.服务的实现必须添加

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 标记

4.方法前面必须添加如下标记

[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]

5.ajax方法中传递的参数名称必须和wcf服务中提供的参数方法名称一致

以下是本人写的代码,标记颜色的是需要注意的地方

服务器端配置文件代码

  1. <system.serviceModel>
  2. <services>
  3. <service name="WcfServiceDemoOne.Service1" behaviorConfiguration="WcfServiceDemoOne.Service1Behavior">
  4. <!-- Service Endpoints -->
  5. <endpoint address="" binding="webHttpBinding" contract="WcfServiceDemoOne.IService1" behaviorConfiguration="HttpBehavior"></endpoint>
  6. <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  7. <host>
  8. <baseAddresses>
  9. <add baseAddress="http://localhost:12079/Service1.svc"/>
  10. </baseAddresses>
  11. </host>
  12. </service>
  13. </services>
  14. <behaviors>
  15. <serviceBehaviors>
  16. <behavior name="WcfServiceDemoOne.Service1Behavior">
  17. <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点-->
  18. <serviceMetadata httpGetEnabled="true"/>
  19. <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
  20. <serviceDebug includeExceptionDetailInFaults="false"/>
  21. </behavior>
  22. </serviceBehaviors>
  23. <endpointBehaviors>
  24. <behavior name="HttpBehavior">
  25. <webHttp/>
  26. </behavior>
  27. </endpointBehaviors>
  28. </behaviors>
  29. </system.serviceModel>
<system.serviceModel>
		<services>
			<service name="WcfServiceDemoOne.Service1" behaviorConfiguration="WcfServiceDemoOne.Service1Behavior">
				<!-- Service Endpoints -->
        <endpoint address="" binding="webHttpBinding" contract="WcfServiceDemoOne.IService1"  behaviorConfiguration="HttpBehavior"></endpoint>

				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
				<host>
					<baseAddresses>
						<add baseAddress="http://localhost:12079/Service1.svc"/>
					</baseAddresses>
				</host>
			</service>
		</services>
		<behaviors>
			<serviceBehaviors>
				<behavior name="WcfServiceDemoOne.Service1Behavior">
					<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点-->
					<serviceMetadata httpGetEnabled="true"/>
					<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
					<serviceDebug includeExceptionDetailInFaults="false"/>
				</behavior>
			</serviceBehaviors>

      <endpointBehaviors>
        <behavior name="HttpBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
		</behaviors>
	</system.serviceModel>



服务器端代码

  1. [ServiceContract]
  2. public interface IService1
  3. {
  4. [OperationContract]
  5. string GetData(int value);
  6. [OperationContract]
  7. City GetDataUsingDataContract(City composite);
  8. [OperationContract]
  9. List<City> GetList();
  10. [OperationContract]
  11. List<City> GetListData(List<City> list);
  12. }
  13. // 使用下面示例中说明的数据约定将复合类型添加到服务操作。
  14. [DataContract]
  15. public class City
  16. {
  17. int seq = 0;
  18. string cityID;
  19. string ctiyName;
  20. [DataMember]
  21. public string CityID
  22. {
  23. get
  24. {
  25. return cityID;
  26. }
  27. set
  28. {
  29. cityID=value;
  30. }
  31. }
  32. [DataMember]
  33. public string CityName
  34. {
  35. get { return ctiyName; }
  36. set { ctiyName = value; }
  37. }
  38. [DataMember]
  39. public int Seq
  40. {
  41. get
  42. { return seq; }
  43. set
  44. { seq = value; }
  45. }
  46. }
[ServiceContract]
    public interface IService1
    {

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        City GetDataUsingDataContract(City composite);

         [OperationContract]
        List<City> GetList();

         [OperationContract]
        List<City> GetListData(List<City> list);
    }


    // 使用下面示例中说明的数据约定将复合类型添加到服务操作。
    [DataContract]
    public class City
    {
        int seq = 0;
        string cityID;
        string ctiyName;
        
         [DataMember]
        public string CityID
        {
           get
           {
               return cityID;
           }
            set
            {
              cityID=value;
            }
        }

        [DataMember]
        public string  CityName
        {
            get { return ctiyName; }
            set { ctiyName = value; }
        }

        [DataMember]
        public int Seq
        {
            get
            { return seq; }
            set
            { seq = value; }
        }
    }


实现代码

  1. [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  2. public class Service1 : IService1
  3. {
  4. [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  5. public string GetData(int value)
  6. {
  7. return string.Format("You entered: {0}", value);
  8. }
  9. #region IService1 成员
  10. [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
  11. public City GetDataUsingDataContract(City composite)
  12. {
  13. City c = new City();
  14. c.CityID = composite.CityID;
  15. c.CityName = composite.CityName;
  16. c.Seq = composite.Seq;
  17. return c;
  18. }
  19. [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
  20. public List<City> GetList()
  21. {
  22. List<City> list = new List<City>();
  23. City cc = new City();
  24. cc.CityID = "1";
  25. cc.CityName="北京";
  26. cc.Seq = 3;
  27. list.Add(cc);
  28. City cc1 = new City();
  29. cc1.CityID = "2";
  30. cc1.CityName = "上海";
  31. cc1.Seq = 4;
  32. list.Add(cc1);
  33. return list;
  34. }
  35. [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
  36. public List<City> GetListData(List<City> list)
  37. {
  38. return list;
  39. }
  40. #endregion
  41. }
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Service1 : IService1
    {
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

        #region IService1 成员

        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
        public City GetDataUsingDataContract(City composite)
        {
            City c = new City();
            c.CityID = composite.CityID;
            c.CityName = composite.CityName;
            c.Seq = composite.Seq;
            return c;
        }

        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
        public List<City> GetList()
        {
            List<City> list = new List<City>();
            City cc = new City();
            cc.CityID = "1";
            cc.CityName="北京";
            cc.Seq = 3;
            list.Add(cc);

            City cc1 = new City();
            cc1.CityID = "2";
            cc1.CityName = "上海";
            cc1.Seq = 4;
            list.Add(cc1);
            return list;
        }

        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
        public List<City> GetListData(List<City> list)
        {
            return list;
        }

        #endregion
    }


客户端调用代码

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WcfServiceDemoOne.WebForm1" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head runat="server">
  5. <title></title>
  6. <script src="jquery-1.7.1.min.js" type="text/javascript"></script>
  7. <script type="text/javascript">
  8. //参数为整数的方法
  9. function fn1()
  10. {
  11. $.ajax({
  12. url: "http://localhost:12079/Service1.svc/GetData",
  13. type: "POST",
  14. contentType: "text/json",
  15. data: '{"value":2}',
  16. dataType: "json",
  17. success: function(returnValue) {
  18. alert(returnValue);
  19. },
  20. error: function() {
  21. alert('error');
  22. }
  23. });
  24. }
  25. //参数为实体类的方法
  26. function fn2() {
  27. $.ajax({
  28. url: "http://localhost:12079/Service1.svc/GetDataUsingDataContract",
  29. type: "POST",
  30. contentType: "application/json",
  31. data: '{"CityID":1,"CityName":"北京","Seq":"3"}',
  32. dataType: "json",
  33. success: function(returnValue) {
  34. alert(returnValue.CityID + ' ' + returnValue.CityName + "--" + returnValue.Seq);
  35. },
  36. error: function() {
  37. alert('error');
  38. }
  39. });
  40. }
  41. //返回值为类集合的方法
  42. function fn3() {
  43. $.ajax({
  44. url: "http://localhost:12079/Service1.svc/GetList",
  45. type: "POST",
  46. contentType: "application/json",
  47. dataType: "json",
  48. success: function(returnValue) {
  49. for (var i = 0; i < returnValue.length; i++) {
  50. alert(returnValue[i].CityID + ' ' + returnValue[i].CityName+'---'+returnValue[i].Seq);
  51. }
  52. },
  53. error: function() {
  54. alert('error');
  55. }
  56. });
  57. }
  58. function fn4() {
  59. $.ajax({
  60. url: "http://localhost:12079/Service1.svc/GetListData",
  61. type: "POST",
  62. contentType: "application/json",
  63. data: '[{"CityID":1,"CityName":"北京","Seq":"3"},{"CityID":3,"CityName":"上海","Seq":"3"}]',
  64. dataType: "json",
  65. success: function(returnValue) {
  66. for (var i = 0; i < returnValue.length; i++) {
  67. alert(returnValue[i].CityID + ' ' + returnValue[i].CityName + '---' + returnValue[i].Seq);
  68. }
  69. },
  70. error: function() {
  71. alert('error');
  72. }
  73. });
  74. }
  75. </script>
  76. </head>
  77. <body>
  78. <form id="form1" runat="server">
  79. <div>
  80. <input id="Button1" type="button" value="调用1" onclick="fn1();" /></div>
  81. <input id="Button2" type="button" value="调用2" onclick="fn2();" />
  82. <br />
  83. <input id="Button3" type="button" value="调用3" onclick="fn3();" /></form>
  84. <br />
  85. <input id="Button4" type="button" value="调用4" onclick="fn4();"/>
  86. </body>
  87. </html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WcfServiceDemoOne.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script src="jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    //参数为整数的方法
       function fn1()
       {
           $.ajax({
           url: "http://localhost:12079/Service1.svc/GetData",
               type: "POST",
               contentType: "text/json",
               data: '{"value":2}',
               dataType: "json",
               success: function(returnValue) {
                   alert(returnValue);
               },
               error: function() {
                   alert('error');
               }
           });

       }

//参数为实体类的方法
       function fn2() {
           $.ajax({
           url: "http://localhost:12079/Service1.svc/GetDataUsingDataContract",
               type: "POST",
               contentType: "application/json",
               data: '{"CityID":1,"CityName":"北京","Seq":"3"}',
               dataType: "json",
               success: function(returnValue) {
               alert(returnValue.CityID + '  ' + returnValue.CityName + "--" + returnValue.Seq);
               },
               error: function() {
                   alert('error');
               }
           });
       }

//返回值为类集合的方法
       function fn3() {
           $.ajax({
               url: "http://localhost:12079/Service1.svc/GetList",
               type: "POST",
               contentType: "application/json",
               dataType: "json",
               success: function(returnValue) {
               for (var i = 0; i < returnValue.length; i++) {
                   alert(returnValue[i].CityID + '  ' + returnValue[i].CityName+'---'+returnValue[i].Seq);
                   }
               },
               error: function() {
                   alert('error');
               }
           });

       }

       function fn4() {
           $.ajax({
           url: "http://localhost:12079/Service1.svc/GetListData",
               type: "POST",
               contentType: "application/json",
               data: '[{"CityID":1,"CityName":"北京","Seq":"3"},{"CityID":3,"CityName":"上海","Seq":"3"}]',
               dataType: "json",
               success: function(returnValue) {
               for (var i = 0; i < returnValue.length; i++) {
                   alert(returnValue[i].CityID + '  ' + returnValue[i].CityName + '---' + returnValue[i].Seq);
               }
               },
               error: function() {
                   alert('error');
               }
           });
       }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <input id="Button1" type="button" value="调用1" onclick="fn1();" /></div>
        <input id="Button2" type="button" value="调用2" onclick="fn2();" />
        <br />
    <input id="Button3" type="button" value="调用3" onclick="fn3();" /></form>
    <br />
    <input id="Button4" type="button" value="调用4"  onclick="fn4();"/>
    
</body>
</html>


demo下载地址:

http://download.youkuaiyun.com/detail/zx13525079024/4144097


使用js+ajax调用WCF服务 使用js+ajax调用WCF服务,博客地址:http://blog.youkuaiyun.com/zaijianluoye110/article/details/25364945 立即下载

相关推荐

ajax以GET和POST方式调用WCF

ajax以GET和POST方式调用WCF,带参数和不带参数的方式都有

JQuery调用WCF服务

一:创建一个wcf服务项目 [ServiceContract] public interface IService1 { [OperationContract] [WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageForma...

weixin_33790053的博客 280

JS跨域调用WCF服务实例(WCF服务宿主到控制台)

JS调用WCF服务实例(WCF服务宿主到控制台),解决Js跨域调用问题 源码实例 wcf宿主到控制台上,并内置js调用服务的源码

【原创经验分享】JQuery(Ajax)调用WCF服务

        最近在学习这个WCF,由于刚开始学 不久,发现网上的一些WCF教程都比较简单,感觉功能跟WebService没什么特别大的区别,但是看网上的介绍,就说WCF比WebService牛逼多少多少,反正我刚开始入门,就没觉得多大区别啦,这次写的东西跟WebService一样,我们写了一个WCF,那当然就是要用的,要用的话,当然不能只能在.NET平台下用了,必须跨平台呀,所以,Ajax能调...

weixin_33871366的博客 176

ARM架构下Horizon Client安装全攻略:从依赖检查到环境变量配置

本文详细介绍了在ARM架构设备上安装VMware Horizon Client的全过程,包括依赖检查、软件包获取、系统部署和环境变量配置。特别针对华为鲲鹏等ARM平台,提供了从基础准备到性能优化的完整指南,帮助用户高效完成虚拟桌面客户端的部署与调优。

github5actions的博客 551

ESP32实战:破解校园网WPA2-Enterprise认证的完整指南

本文详细介绍了如何使用ESP32开发板破解校园网WPA2-Enterprise认证的完整指南。通过硬件准备、环境搭建、核心代码实现及常见问题排查,帮助开发者解决企业级WiFi连接难题,特别适用于校园网环境下的物联网设备开发。

weixin_29194817的博客 453

ajax请求wcf,JS($.ajax)调用WCF 遇到的各种坑

本文以一个生成、获取“客户列表”的demo来介绍如何用js调用wcf,以及遇到的各种问题。1 创建WCF服务1.1 定义接口创建一个接口,指定用json的格式:[ServiceContract]interface IQueue{[OperationContract][WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped...

weixin_39968410的博客 474

莫兰指数stata命令_一文读懂16个sp系列stata空间计量命令及应用

spcompress:Compress Stata-format shapefile压缩数据成stata格式的shapefile2、Looking at data/观测数据2、Looking at data/观测数据grmap:Graph choropleth maps绘制等值区域图spdistance:Calculator for distance between places计算区域之间距离3...

weixin_39719989的博客 821

ajax调用wcf rest服务器,PostMan 调用WCF Rest服务

问题描述:现在有已有的WCF服务,但是ajax是不能请求到这个服务的;需要把WCF转成WCF REST 的风格。以下是从WCF转 WCF REST的步骤1.首先在接口定义的地方加上 请求WebInvoke http的请求动作如下:[OperationContract][WebInvoke(Method = "POST", UriTemplate = "Login", ResponseFormat ...

weixin_31589747的博客 439

Dify如何实现自主学习

摘要:Dify通过构建感知-决策-执行-反馈的闭环实现"自主学习",本质是打造能自动获取信息、更新知识库并调整策略的Agent工作流。核心包括:1)建立知识库作为记忆体;2)搭建感知与执行工具获取实时信息;3)通过工作流编排决策"大脑",包含LLM决策节点、行动执行节点和反馈反思节点。典型应用如根据用户反馈优化回答风格,通过存储反思日志到知识库实现持续优化。这种机制使智能体能基于新数据和经验不断自我改进。

专注于技术研发行业技术主要有AI人工智能视觉识别、物联网技术、电商平台、app原生技术、微信小程序、鸿蒙语言开发、办公企业oa、ERP等,致力于做东半球最优秀的程序员 725

EBOM转MBOM实战:华为云数字工厂如何5步搞定BOM自动转换(含避坑指南)

本文详细解析了华为云数字工厂平台如何通过五步自动化流程实现EBOM到MBOM的高效转换,涵盖模型预配置、逻辑流编排、工艺属性注入等关键步骤,并提供了多工厂差异化配置、历史数据迁移等典型场景的避坑指南。该方案显著提升转换效率,降低差错率,助力企业实现数字化转型。

weixin_29215391的博客 267

WCF和ASMX WebService的区别是什么

最基本的区别在于,ASMX或者ASP.NET WebService是用来通过基于HTTP的SOAP来实现通讯。但WCF可以使用任意协议(HTTP,TCP/IP,MSMQ,NamedPipes等),消息封装可以使用任意格式(默认SOAP)。 更多的细节比较,可以参考:WCF Vs ASMX 怎么理解WCF的Service EndPoints? 对于WCF服务来说,Endpoints暴漏了其被调

XMM_1030的专栏 3973

反激变压器设计学习笔记

反激变压器匝比感量设计

m0_55419117的博客 5261

ajax请求wcf,jQuery ajax调用WCF服务实例

恩,在由瘦客户端转换成胖浏览器端的“潮流”下,必然要使用JavaScript调用后台的各种服务。屌丝所维护的产品通信都是使用的WCF服务,因此必然要学习这样的内容。借用jQuery强大的库,使用JavaScript访问WCF服务非常简便。同事研究了一个breeze库,那么屌丝就来试验一下ajax。这里把实现简单地记录以便马克一下,以后忘了就看这篇日志来作弊。一、更改WCF服务的配置默认情况下,WC...

weixin_39980360的博客 363

C#中通过Mapster实现轻量级高效对象映射器:从零到精通

本文介绍了.NET生态中高性能对象映射库Mapster的完整使用指南。从基础安装(通过NuGet包)到快速入门示例,展示了如何实现简单对象映射。进一步讲解了自定义映射规则、命名不一致属性的处理方式,以及如何在ASP.NET Core中集成Mapster服务。针对复杂场景,详细解析了嵌套对象映射的配置技巧,并提供了性能优化方案(如预编译映射器)和调试技巧(启用调试模式、捕获映射异常)。通过完整的代码实践,帮助开发者高效解决从基础到高级的对象映射需求。

墨夶的博客 740

2026华为OD机试(Python)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,Python实现。

MISAYAONE的博客 28万+

【转载】Ajax调用Wcf服务

最近在学习这个WCF,由于刚开始学 不久,发现网上的一些WCF教程都比较简单,感觉功能跟WebService没什么特别大的区别,但是看网上的介绍,就说WCF比WebService牛逼多少多少,反正我刚开始入门,就没觉得多大区别啦,这次写的东西跟WebService一样,我们写了一个WCF,那当然就是要用的,要用的话,当然不能只能在.NET平台下用了,必须跨平台呀,所以,Ajax能调用,这...

dianda6073的专栏 157

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

WCF 之 AJax前台调用WCF服务

调用WCF服务,我们一般都是中客户端的配置文件中配置好WCF服务的终结点,然后中后台代码中实例化WCF服务,然后调用其中的方法,今天给大家介绍一种,不需要配置终结点,直接中前台通过AJax方法调用WCF服务的方法。 首先我们先创建一个控制台WCF服务 契约接口: using System.ServiceModel; using System.ServiceModel.

等一个故事 5995

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

ajax 访问wcf服务,实现支持AJAX的WCF服务 - 来自JQuery的调用没有响应

我正在浏览MSDN上发布的一个我无法开始工作的示例。我在VS2015中有一个带有AJAX Enabled WCF服务的ASP Web Form项目。我点击了Cntrl-F5,它运行正常。我尝试在浏览器中输入URI并获得相应的响应。:nth-of-type然后我将一个启用Ajax的ScriptManager添加到Default.aspx设计视图中,然后右键单击“属性”#39;视图。我添加了我的服务名...

weixin_36481965的博客 357

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

jQuery Ajax调用WCF服务详细教程

jQuery Ajax调用WCF服务详细教程 这篇文章主要介绍了jQuery Ajax调用WCF服务详细教程,本文讲解了从WFC编程到JQUERY调用的详细步骤,并总结了使用中遇到的问题和解决方法,需要的朋友可以参考下 <div id="content"> <p>这两天在写基于WCF服务的后台...

ITMAN009的博客 624

jQuery AJAX调用WCF服务

在网络上经常看到一些初学者提问怎么在AJAX中或用Javascript调用WCF服务,本文将简要给初学者介绍如何在AJAX中或用Javascript调用WCF服务以及注意事项。为了便于讲解,我们首先创建一个WCF服务,服务和服务数据定义如下: //数据契约 [DataContract] public class Person { [DataMemb

mengyulove的专栏 684

用jQuery AJAX调用WCF服务

用jQuery AJAX调用WCF服务 作者: cokkiy  来源: 博客园  发布时间: 2009-10-23 10:14  阅读: 5808 次  推荐: 2   原文链接   [收藏]     在网络上经常看到一些初学者提问怎么在AJAX中或用Javascript调用WCF服务,本文将简要给初学者介绍如何在AJAX中或用Javascript调用WCF服务以及注意事

hsg77的专栏 884

ajax内调用WCF服务

WCF可以当作WebService一样被调用,在html内通过ajax调用WCF服务的方法如下: 1、新建一个WCF服务的网站项目; 2、在项目内增加一个新项:启用了ajax的WCF服务; 3、在对应的XXService.svc.cs文件内增加方法。例: [OperationContract] [WebGet] public void DoWork() { ...

weixin_30535843的博客 190

如何让WCF服务更好地支持Web Request和AJAX调用

WCF的确不错,它大大地简化和统一了服务的开发。但也有不少朋友问过我,说是在非.NET客户程序中,有何很好的方法直接调用服务吗?还有就是在AJAX的代码中(js)如何更好地调用WCF服务呢? 我首先比较推荐的是可以通过页面静态方法等方式来转接对WCF的服务。尤其是WCF是属于别的网站的一部分的时候。 但今天我要讲解一下,如果和WCF在一个网站内部,那么js脚本应该如何更好地调用WCF呢?或者说,为了支持js更好地访问,WCF服务在设计的时候应该注意什么呢? 1. 创建服务 2. 修改接口 为了做演示,我

陈希章@中国 2279
上一篇: sql常用小知识 ---ISNULL
下一篇: c#连接Redis---(1)Redis的安装与配置
ArvinStudy
博客等级 码龄15年 83粉丝 193原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值