Ext.Net 2 - Calling WCF Service

  1. #1

    Ext.Net 2 - Calling WCF Service

    Hi Everyone,

    I'm trying to call my data from a WCF service, so far without success. Calling my service trough my browser works just fine, and i'm getting all of my desired results. But when i call my service from a combobox store with ajaxproxy, i'm not getting results displayed. Does anyone knows where things go wrong?

    My combobox:
                                <ext:ComboBox ID="ZoekProductenOpArtikelnummerComboBox" runat="server" DisplayField="Artikelnummer" ValueField="Artikelnummer" TypeAhead="false">
                                    <Store>
                                        <ext:Store runat="server" AutoLoad="false">
                                            <Proxy>
                                                <ext:AjaxProxy Url="~/services/Service.svc/ZoekArtikelenOpArtikelnummer">
                                                    <ActionMethods Read="GET" />
                                                    <Reader>
                                                        <ext:JsonReader Root="Data" TotalProperty="TotalRecords" />
                                                    </Reader>
                                                </ext:AjaxProxy>
                                            </Proxy>
                                            <Model>
                                                <ext:Model runat="server" IDProperty="Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Id" Type="Int" />
                                                        <ext:ModelField Name="Artikelnummer" Type="String" />
                                                        <ext:ModelField Name="Merk" Type="String" />
                                                        <ext:ModelField Name="Verkoopprijs" Type="Float" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>

    My Service + Method:
            [OperationContract]
            [WebGet(BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            public Paging<Artikel> ZoekArtikelenOpArtikelnummer(string filter)
            {
                var start = 0;
                var limit = 10;
                var sort = string.Empty;
                var dir = string.Empty;
                var query = string.Empty;
    
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.Params["start"]))
                {
                    start = int.Parse(HttpContext.Current.Request.Params["start"]);
                }
    
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.Params["limit"]))
                {
                    limit = int.Parse(HttpContext.Current.Request.Params["limit"]);
                }
    
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.Params["sort"]))
                {
                    sort = HttpContext.Current.Request.Params["sort"];
                }
    
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.Params["dir"]))
                {
                    dir = HttpContext.Current.Request.Params["dir"];
                }
    
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.Params["query"]))
                {
                    query = HttpContext.Current.Request.Params["query"];
                }
    
                return ArtikelPaging(start, limit, sort, dir, query);
    
                //Paging<Artikel> artikelen = ArtikelPaging(start, limit, sort, dir, query);
    
                //return string.Format("{{totaal:{1},'items':{0}}}", JSON.Serialize(artikelen.Data), artikelen.TotalRecords);
            }
    My Result From The Service:
    {"d":{"__type":"PagingOfArtikelUO6PZr5d:#Ext.Net","Data":[{"__type":"Artikel:#Beheer.Models.Sync","Artikelnummer":150039,"Categorie":"403","Datum_Gewijzigd":"\/Date(1346931628497+0200)\/","Id":1,"Merk":"CEBO","Promo_01":0.0000,"Promo_01_tot":null,"Promo_01_van":null,"Promo_02":0.0000,"Promo_02_tot":null,"Promo_02_van":null,"Promo_03":0.0000,"Promo_03_tot":null,"Promo_03_van":null,"Verkoopprijs":29.9900}],"TotalRecords":3108}}
  2. #2
    try change json reader like this

    <ext:JsonReader Root="d.Data" TotalProperty="d.TotalRecords" />
  3. #3
    Quote Originally Posted by PetrSnobelt View Post
    try change json reader like this

    <ext:JsonReader Root="d.Data" TotalProperty="d.TotalRecords" />
    Thanks PetrSnobelt, That did the trick, and everything works fine now. I feel so stupid...

Similar Threads

  1. Need Help Using a Web Service !
    By metallica87 in forum 1.x Help
    Replies: 2
    Last Post: Mar 19, 2012, 4:25 AM
  2. [CLOSED] web service problem
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 02, 2009, 10:18 AM
  3. Replies: 6
    Last Post: Jun 04, 2009, 1:58 PM
  4. Software as a service?
    By dbassett74 in forum Licensing
    Replies: 1
    Last Post: May 21, 2009, 4:02 PM
  5. [CLOSED] Need Help Using a Web Service with a Grid
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 23, 2008, 10:15 AM

Tags for this Thread

Posting Permissions