PDA

View Full Version : JSONStore receive JSON between xml tags



Cloetn
28 Apr 2011, 11:07 PM
Hi,

I have some experience with ExtJS but I recently switched to Sencha Touch to make a small Mobile site.

I'm just trying to get some objects from a webservice with a Jsonstore but I receive some bizar values :-?


Ext.regModel('Document', {
fields: ['Name', 'Author']
});

var store = new Ext.data.JsonStore({
model: 'Document',
proxy: {
type: 'ajax',
url: 'QMSMobile.asmx/HelloWorld',
reader: {
type: 'json'
}
},
autoLoad: true
});


[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
public string HelloWorld()
{
Document newDocument = new Document()
{
Author = "Anthony",
Name = "Document1.0"
};

return JsonConvert.SerializeObject(newDocument);
}



This is what I receive:

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">{"Name":"Boekje","Author":"Anthony"}</string>

This isn't the result I was expecting. Do you have any idea how this comes? If I manually surf to the webserivce and invoke it I receive the right JSON without the xml tags.

Thanks for the help

realjax
30 Apr 2011, 11:05 AM
If I manually surf to the webserivce and invoke it I receive the right JSON without the xml tags.


I suspect that this is not the case. Looks like the webservice returns the data in XML format, and if you look at the results from invoking the webservice it *migh* look allright, because the browser simply doesn't render the xml tags. Manually invoke it again but then look at the page source, it'll probably also show the xml tags.