第一节:ExtJS调用WCF系列-----实现JSON传递

首先我们打开我们的VS 新建一个Asp.Net WebApplication Project,(不要给我说新建网站,我讨厌那个东东) 命名为ExtJSAndWCFChapter1 如图:
第一节:ExtJS调用WCF系列-----实现JSON传递
接下来我们在该项目中新建一个实体类文件和一个AJAX—Enabled WCF SERVICE,分别命名为Employee.cs 和EmployeeService.svc
第一节:ExtJS调用WCF系列-----实现JSON传递
下面去ExtJS.Com网站下载一个ExtJS 2.0 ,解压缩后拷贝至Default.aspx相同目录下,并包括在项目中。如图:
第一节:ExtJS调用WCF系列-----实现JSON传递
下面开始编写代码:先编写Employee.cs的代码,代码如下:
第一节:ExtJS调用WCF系列-----实现JSON传递usingSystem;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Data;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Configuration;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Linq;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Web;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Web.Security;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Web.UI;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Web.UI.HtmlControls;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Web.UI.WebControls;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Web.UI.WebControls.WebParts;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Xml.Linq;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Runtime.Serialization;
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
namespaceExtJSAndWCFChapter1
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递[DataContract]
第一节:ExtJS调用WCF系列-----实现JSON传递
publicclassEmployee
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递[DataMember]
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
publicGuidEmployeeID第一节:ExtJS调用WCF系列-----实现JSON传递{set;get;}
第一节:ExtJS调用WCF系列-----实现JSON传递[DataMember]
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
publicstringCnName第一节:ExtJS调用WCF系列-----实现JSON传递{set;get;}
第一节:ExtJS调用WCF系列-----实现JSON传递[DataMember]
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
publicboolSex第一节:ExtJS调用WCF系列-----实现JSON传递{set;get;}
第一节:ExtJS调用WCF系列-----实现JSON传递[DataMember]
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
publicintAge第一节:ExtJS调用WCF系列-----实现JSON传递{set;get;}
第一节:ExtJS调用WCF系列-----实现JSON传递[DataMember]
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
publicDateTimeBirthday第一节:ExtJS调用WCF系列-----实现JSON传递{set;get;}
第一节:ExtJS调用WCF系列-----实现JSON传递[DataMember]
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
publicstringEmail第一节:ExtJS调用WCF系列-----实现JSON传递{set;get;}
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递

接下来编写EmployeeService.cs的代码,代码如下:
第一节:ExtJS调用WCF系列-----实现JSON传递usingSystem;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Linq;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Runtime.Serialization;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.ServiceModel;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.ServiceModel.Activation;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.ServiceModel.Web;
第一节:ExtJS调用WCF系列-----实现JSON传递
usingSystem.Collections.Generic;
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
namespaceExtJSAndWCFChapter1
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递[ServiceContract(Namespace
="")]
第一节:ExtJS调用WCF系列-----实现JSON传递[AspNetCompatibilityRequirements(RequirementsMode
=AspNetCompatibilityRequirementsMode.Allowed)]
第一节:ExtJS调用WCF系列-----实现JSON传递
publicclassEmployeeService
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递
//Add[WebGet]attributetouseHTTPGET
第一节:ExtJS调用WCF系列-----实现JSON传递
[OperationContract]
第一节:ExtJS调用WCF系列-----实现JSON传递
publicvoidDoWork()
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递
//Addyouroperationimplementationhere
第一节:ExtJS调用WCF系列-----实现JSON传递
return;
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
//Addmoreoperationshereandmarkthemwith[OperationContract]
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
/**////<summary>
第一节:ExtJS调用WCF系列-----实现JSON传递
///创建一个实体,实体由客户端传递
第一节:ExtJS调用WCF系列-----实现JSON传递
///</summary>
第一节:ExtJS调用WCF系列-----实现JSON传递
///<paramname="emp"></param>
第一节:ExtJS调用WCF系列-----实现JSON传递
///<returns></returns>

第一节:ExtJS调用WCF系列-----实现JSON传递[OperationContract]
第一节:ExtJS调用WCF系列-----实现JSON传递[WebInvoke(BodyStyle
=WebMessageBodyStyle.Wrapped,RequestFormat=WebMessageFormat.Json,ResponseFormat=WebMessageFormat.Json,UriTemplate="/Create")]
第一节:ExtJS调用WCF系列-----实现JSON传递
publicGuidCreate(Employeeemp)
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递NotNull(emp.CnName,
"CnName");
第一节:ExtJS调用WCF系列-----实现JSON传递
returnGuid.NewGuid();
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
/**////<summary>
第一节:ExtJS调用WCF系列-----实现JSON传递
///获取一个实体
第一节:ExtJS调用WCF系列-----实现JSON传递
///</summary>
第一节:ExtJS调用WCF系列-----实现JSON传递
///<paramname="id"></param>
第一节:ExtJS调用WCF系列-----实现JSON传递
///<returns></returns>

第一节:ExtJS调用WCF系列-----实现JSON传递[OperationContract]
第一节:ExtJS调用WCF系列-----实现JSON传递[WebInvoke(BodyStyle
=WebMessageBodyStyle.Bare,RequestFormat=WebMessageFormat.Json,ResponseFormat=WebMessageFormat.Json,UriTemplate="/Get")]
第一节:ExtJS调用WCF系列-----实现JSON传递
publicEmployeeGet(intid)
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递
if(id!=1)thrownewArgumentException("Expected1forID");
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
returnnewEmployee()第一节:ExtJS调用WCF系列-----实现JSON传递{EmployeeID=Guid.NewGuid(),CnName="Xiaozhuang",Sex=true,Age=28,Email="[email protected]",Birthday=newDateTime(1979,02,02)};
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
/**////<summary>
第一节:ExtJS调用WCF系列-----实现JSON传递
///获取所有实体
第一节:ExtJS调用WCF系列-----实现JSON传递
///</summary>
第一节:ExtJS调用WCF系列-----实现JSON传递
///<returns></returns>

第一节:ExtJS调用WCF系列-----实现JSON传递[OperationContract]
第一节:ExtJS调用WCF系列-----实现JSON传递[WebInvoke(BodyStyle
=WebMessageBodyStyle.Wrapped,RequestFormat=WebMessageFormat.Json,ResponseFormat=WebMessageFormat.Json,UriTemplate="/GetAll")]
第一节:ExtJS调用WCF系列-----实现JSON传递
publicList<Employee>GetAll()
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递
returnnewList<Employee>
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
newEmployee()第一节:ExtJS调用WCF系列-----实现JSON传递{EmployeeID=Guid.NewGuid(),CnName="CnName",Sex=true,Age=28,Email="[email protected]",Birthday=newDateTime(1979,02,02)},
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
newEmployee()第一节:ExtJS调用WCF系列-----实现JSON传递{EmployeeID=Guid.NewGuid(),CnName="CnName1",Sex=false,Age=28,Email="[email protected]",Birthday=newDateTime(1979,02,02)}
第一节:ExtJS调用WCF系列-----实现JSON传递}
;
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
/**////<summary>
第一节:ExtJS调用WCF系列-----实现JSON传递
///获取num个实体
第一节:ExtJS调用WCF系列-----实现JSON传递
///</summary>
第一节:ExtJS调用WCF系列-----实现JSON传递
///<paramname="num"></param>
第一节:ExtJS调用WCF系列-----实现JSON传递
///<returns></returns>

第一节:ExtJS调用WCF系列-----实现JSON传递[OperationContract]
第一节:ExtJS调用WCF系列-----实现JSON传递[WebInvoke(BodyStyle
=WebMessageBodyStyle.Bare,RequestFormat=WebMessageFormat.Json,ResponseFormat=WebMessageFormat.Json,UriTemplate="/GetByNum")]
第一节:ExtJS调用WCF系列-----实现JSON传递
publicList<Employee>GetByNum(intnum)
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递
if(num.ToString()=="")thrownewArgumentException("参数错误!");
第一节:ExtJS调用WCF系列-----实现JSON传递List
<Employee>emplist=newList<Employee>();
第一节:ExtJS调用WCF系列-----实现JSON传递
for(inti=1;i<=num;i++)
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递Employeeemp
=newEmployee()第一节:ExtJS调用WCF系列-----实现JSON传递{EmployeeID=Guid.NewGuid(),CnName=i+"CnName",Sex=true,Age=i*10,Email=i+"[email protected]",Birthday=newDateTime(1979,02,02)};
第一节:ExtJS调用WCF系列-----实现JSON传递emplist.Add(emp);
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递
returnemplist;
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
privatestaticvoidNotNull<T>(To,stringparamName)whereT:class
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递
if(o==null)thrownewArgumentNullException(paramName);
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递

主要就是这一句 [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/Create")]
意思就是说这个方法传递输入和输出参数都是Json形式,并且可以用后面加Create的形式来访问该方法,至于前面那个BodyStyle = WebMessageBodyStyle.Wrapped是什么意思留着下节详细说明

接下来修改Web.Config文件,其实只是是把<enableWebScript /> 替换为<webHttp/>代码如下(一部分)


第一节:ExtJS调用WCF系列-----实现JSON传递<system.serviceModel>
第一节:ExtJS调用WCF系列-----实现JSON传递
<behaviors>
第一节:ExtJS调用WCF系列-----实现JSON传递
<endpointBehaviors>
第一节:ExtJS调用WCF系列-----实现JSON传递
<behaviorname="ExtJSAndWCFChapter1.EmployeeServiceAspNetAjaxBehavior">
第一节:ExtJS调用WCF系列-----实现JSON传递
<!--<enableWebScript/>-->
第一节:ExtJS调用WCF系列-----实现JSON传递
<webHttp/>
第一节:ExtJS调用WCF系列-----实现JSON传递
</behavior>
第一节:ExtJS调用WCF系列-----实现JSON传递
</endpointBehaviors>
第一节:ExtJS调用WCF系列-----实现JSON传递
</behaviors>
第一节:ExtJS调用WCF系列-----实现JSON传递
<serviceHostingEnvironmentaspNetCompatibilityEnabled="true"/>
第一节:ExtJS调用WCF系列-----实现JSON传递
<services>
第一节:ExtJS调用WCF系列-----实现JSON传递
<servicename="ExtJSAndWCFChapter1.EmployeeService">
第一节:ExtJS调用WCF系列-----实现JSON传递
<endpointaddress=""behaviorConfiguration="ExtJSAndWCFChapter1.EmployeeServiceAspNetAjaxBehavior"binding="webHttpBinding"contract="ExtJSAndWCFChapter1.EmployeeService"/>
第一节:ExtJS调用WCF系列-----实现JSON传递
</service>
第一节:ExtJS调用WCF系列-----实现JSON传递
</services>
第一节:ExtJS调用WCF系列-----实现JSON传递
</system.serviceModel>

现在可以编译并访问那个EmployeeService.svc文件,后面加上 UriTemplate的值:例如http://localhost:1481/EmployeeService.svc/get。会得到“Method not allowed”的提示。如果访问出现错误,请确认修改的Web.Config是否正确。
接下来编写Default.aspx的代码:代码如下
第一节:ExtJS调用WCF系列-----实现JSON传递<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="ExtJSAndWCFChapter1._Default"%>
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
<htmlxmlns="http://www.w3.org/1999/xhtml">
第一节:ExtJS调用WCF系列-----实现JSON传递
<headrunat="server">
第一节:ExtJS调用WCF系列-----实现JSON传递
<title>UntitledPage</title>
第一节:ExtJS调用WCF系列-----实现JSON传递
<linkrel="stylesheet"type="text/css"href="ExtJS/resources/css/ext-all.css"/>
第一节:ExtJS调用WCF系列-----实现JSON传递
<!--GC-->
第一节:ExtJS调用WCF系列-----实现JSON传递
<!--LIBS-->
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
<scripttype="text/javascript"src="ExtJS/adapter/ext/ext-base.js"></script>
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
<scripttype="text/javascript"src="ExtJS/ext-all-debug.js"></script>
第一节:ExtJS调用WCF系列-----实现JSON传递
<scripttype="text/javascript"src="ExtJS/ext-all.js"></script>
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
<!--ENDLIBS-->
第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递
<scripttype="text/javascript"language="javascript">
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递Ext.onReady(function()
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递
//设置Content-Type为application/json形式
第一节:ExtJS调用WCF系列-----实现JSON传递
Ext.lib.Ajax.defaultPostHeader='application/json';
第一节:ExtJS调用WCF系列-----实现JSON传递
//访问失败的统一回调函数
第一节:ExtJS调用WCF系列-----实现JSON传递
varonFailure=function(r,opts)
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递Ext.
get("errors").insertHtml('afterend','<br/><br/>'+r.responseText,false);
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递
//客户端创建一个实体
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
varrequest=第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递emp:
第一节:ExtJS调用WCF系列-----实现JSON传递{CnName:'xiaozhuang',
第一节:ExtJS调用WCF系列-----实现JSON传递Sex:
1,
第一节:ExtJS调用WCF系列-----实现JSON传递Age:
28,
第一节:ExtJS调用WCF系列-----实现JSON传递Birthday:
'/Date(62831853071)/',
第一节:ExtJS调用WCF系列-----实现JSON传递Email:
'[email protected]'
第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递}

第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递Ext.Ajax.request(
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递url:
'/EmployeeService.svc/Create',//要访问的方法地址
第一节:ExtJS调用WCF系列-----实现JSON传递
method:'POST',
第一节:ExtJS调用WCF系列-----实现JSON传递
params:Ext.util.JSON.encode(request),//把输入参数进行JSON编码
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递
success:function(response,options)第一节:ExtJS调用WCF系列-----实现JSON传递{Ext.get('create-p').update(response.responseText);},//输出方法返回结果
第一节:ExtJS调用WCF系列-----实现JSON传递
failure:onFailure
第一节:ExtJS调用WCF系列-----实现JSON传递}
);
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递Ext.Ajax.request(
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递url:
'/EmployeeService.svc/Get',
第一节:ExtJS调用WCF系列-----实现JSON传递method:
'POST',
第一节:ExtJS调用WCF系列-----实现JSON传递
params:Ext.util.JSON.encode(1),
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递success:function(response,options)
第一节:ExtJS调用WCF系列-----实现JSON传递{Ext.get('get-p').update(response.responseText);},
第一节:ExtJS调用WCF系列-----实现JSON传递failure:onFailure
第一节:ExtJS调用WCF系列-----实现JSON传递}
);
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递Ext.Ajax.request(
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递url:
'EmployeeService.svc/GetAll',
第一节:ExtJS调用WCF系列-----实现JSON传递method:
'POST',
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递success:function(response,options)
第一节:ExtJS调用WCF系列-----实现JSON传递{Ext.get('getall-p').update(response.responseText);},
第一节:ExtJS调用WCF系列-----实现JSON传递failure:onFailure
第一节:ExtJS调用WCF系列-----实现JSON传递}
);
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递Ext.Ajax.request(
第一节:ExtJS调用WCF系列-----实现JSON传递{
第一节:ExtJS调用WCF系列-----实现JSON传递url:
'EmployeeService.svc/GetByNum',
第一节:ExtJS调用WCF系列-----实现JSON传递method:
'POST',
第一节:ExtJS调用WCF系列-----实现JSON传递
params:Ext.util.JSON.encode(8),
第一节:ExtJS调用WCF系列-----实现JSON传递第一节:ExtJS调用WCF系列-----实现JSON传递success:function(response,options)
第一节:ExtJS调用WCF系列-----实现JSON传递{Ext.get('GetByNum-p').update(response.responseText);},
第一节:ExtJS调用WCF系列-----实现JSON传递failure:onFailure
第一节:ExtJS调用WCF系列-----实现JSON传递}
);
第一节:ExtJS调用WCF系列-----实现JSON传递}
);
第一节:ExtJS调用WCF系列-----实现JSON传递
</script>
第一节:ExtJS调用WCF系列-----实现JSON传递
</head>
第一节:ExtJS调用WCF系列-----实现JSON传递
<body>
第一节:ExtJS调用WCF系列-----实现JSON传递
<formid="form1"runat="server">
第一节:ExtJS调用WCF系列-----实现JSON传递
<div>
第一节:ExtJS调用WCF系列-----实现JSON传递
<h3>
第一节:ExtJS调用WCF系列-----实现JSON传递Create:
</h3>
第一节:ExtJS调用WCF系列-----实现JSON传递
<pid="create-p">
第一节:ExtJS调用WCF系列-----实现JSON传递
</p>
第一节:ExtJS调用WCF系列-----实现JSON传递
<h3>
第一节:ExtJS调用WCF系列-----实现JSON传递Get:
</h3>
第一节:ExtJS调用WCF系列-----实现JSON传递
<pid="get-p">
第一节:ExtJS调用WCF系列-----实现JSON传递
</p>
第一节:ExtJS调用WCF系列-----实现JSON传递
<h3>
第一节:ExtJS调用WCF系列-----实现JSON传递GetAll:
</h3>
第一节:ExtJS调用WCF系列-----实现JSON传递
<pid="getall-p">
第一节:ExtJS调用WCF系列-----实现JSON传递
</p>
第一节:ExtJS调用WCF系列-----实现JSON传递
<h3>
第一节:ExtJS调用WCF系列-----实现JSON传递GetByNum:
</h3>
第一节:ExtJS调用WCF系列-----实现JSON传递
<pid="GetByNum-p">
第一节:ExtJS调用WCF系列-----实现JSON传递
</p>
第一节:ExtJS调用WCF系列-----实现JSON传递
<pid="errors">
第一节:ExtJS调用WCF系列-----实现JSON传递
</p>
第一节:ExtJS调用WCF系列-----实现JSON传递
</div>
第一节:ExtJS调用WCF系列-----实现JSON传递
</form>
第一节:ExtJS调用WCF系列-----实现JSON传递
</body>
第一节:ExtJS调用WCF系列-----实现JSON传递
</html>
第一节:ExtJS调用WCF系列-----实现JSON传递

最终的运行效果:
第一节:ExtJS调用WCF系列-----实现JSON传递
源代码下载在这里