Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Analysis of WCF and ExtJs implementation Project

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about the case analysis of WCF and ExtJs implementation projects, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

When I wrote that I used Restful to call WCF for upload and download, I was surprised to find that WCF supports the return of native data (Raw), which solves the problem in cross-domain calls between ExtJs and Wcf: the returned data must meet the format. According to the project implemented in the cross-domain access between WCF and ExtJs, the native data is returned to Extjs through the joint use of Stream and ContentType, thus realizing the cross-domain call.

* step: in the PageGridService.svc backend code, add the operation contract GetProductsByPageCorssDomain as follows:

[OperationContract] [WebInvoke (Method = "*", ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetProductsByPageCorssDomain?start= {start} & limit= {limit} & callback= {callback}")] public Stream GetProductsByPageCorssDomain (int start, int limit,string callback) {ProductsDataContext productDbContext = new ProductsDataContext (); IQueryable res = productDbContext.Product.Select (product = > product); PageData returnData = new PageData (); returnData.TotolRecord = res.ToArray (). Length; resres = res.Skip (start); resres = res.Take (limit) ReturnData.Data = res.ToArray (); System.Runtime.Serialization.Json.DataContractJsonSerializer formater = new System.Runtime.Serialization.Json.DataContractJsonSerializer (typeof (PageData)); MemoryStream ms = new MemoryStream (); formater.WriteObject (ms, returnData); ms.Position = 0; StreamReader sr = new StreamReader (ms); string objContent = sr.ReadToEnd (); string returnStr = callback+ "(" + objContent+ ")"; sr.Close (); ms = new MemoryStream (); StreamWriter sw = new StreamWriter (ms); sw.AutoFlush = true Sw.Write (returnStr); ms.Position = 0; WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain"; return ms;}

Step 2: create a new htm page in the project: PageGridCorssDomainWithRow.htm, the code is:

ExtJs+WCF+LINQ to create pagination Grid ExtJs+WCF+LINQ to create pagination cross-domain Grid after reading the above, do you have any further understanding of the case analysis of WCF and ExtJs implementation projects? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report