1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    1
    Vote Rating
    0
    rwhitworth is on a distinguished road

      0  

    Default JSON Being Returned from asmx web service ScriptMethod

    JSON Being Returned from asmx web service ScriptMethod


    I have created a c# web service to return JSON for some of our SharePoint data. Below is the web service code:

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
    public string GetJSON() {
    ExecutiveTeamDataContext dc = new ExecutiveTeamDataContext(new Uri("http://connect.xxxxx.com/workgroups/ec/_vti_bin/listdata.svc"));
    dc.Credentials = new NetworkCredential("xxxxx", "xxxxx", "xx");
    var items = from c in dc.WorkgroupTasks where c.Id == 10
    select new
    {
    TaskID = c.Id,
    TaskTitle = c.Description1,
    TaskNextAction = c.NextActionStatus,
    };


    JavaScriptSerializer js = new JavaScriptSerializer();
    string strJson = js.Serialize(items);
    return strJson;
    }



    Following is what is being returned to sencha

    {"d":"[{\"TaskID\":10,\"TaskTitle\":\"\u003cdiv\u003eAnalysis of Capital Accounts\u003c/div\u003e\",\"TaskNextAction\":\"\u003cdiv\u003eUse model to develop presentation to bonding company.\u003c/div\u003e\"}]"}


    Here is the code I used to read the response
    Ext.setup(
    {
    fullscreen: true,
    glossOnIcon: false,
    onReady: function ()
    {
    // to test the call
    Ext.Ajax.request(
    {
    url: 'https://mobile.*****.com/spclient/webservice.asmx/GetJSON',
    method: 'GET',
    jsonData: { "Alert": {} },
    headers: { 'Content-Type': 'application/json;charset=utf-8'
    },
    success: function (response, opts)
    {
    console.log(response.responseText);
    },
    failure: function (response, opts)
    {
    console.log(response.responseText);
    }
    })
    }
    })


    Finally, here is the code I am using to try to bind the data. When it runs, I get a count in the console of 193 records, even though the web service is returning only the one record shown above. Also, nothing is displayed in the grid, just 193 empty rows. My guess is that it has something to do with the " directly after "d" : " since many of the examples I have seen do not include this. So if the root is d, it seems like everything else is being wrapped in an extra pair of quotes.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Is this 193 characters long? Did you decode it via Ext.decode(response.responseText) ?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi