Get the App
SLTechnology News&Howtos  ›  Development  › 

Case Analysis of WCF and ExtJs implementation Project

Shulou Source: shulou.com Published: 2022-06-02 11:40:36 10月14日 Update

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.

Tags: Project code content data instance case analysis analysis inter-support surprise upload and download background contract way more format knowledge article industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Technology Linux vpn Microsoft