PDA

View Full Version : How to implement web services(WCF Rest service) in sencha touch 2



vipsshan
17 Jul 2012, 5:37 AM
Hi,
How to implement WCF Rest services in sencha Touch 2. Could you send me the example.

Thanks & Regards
Vipin

mitchellsimoens
19 Jul 2012, 4:15 AM
Use a store with a proxy or an ajax request

vipsshan
20 Jul 2012, 4:09 AM
Hi,
Actually on Sencha site it is written that if you are calling a webservice wich is out side the domain you should use Jsonp, but when I am using it as follows:-
Ext.define("App.store.Contacts", {
extend:"Ext.data.Store",
// requires: [
// "Ext.data.proxy.JsonP"
// ],
config:{
model:"App.model.Contacts",
// autoLoad:true,
sorters:"first_name",
grouper: function(record){
return record.get('first_name')[0];
},
proxy:{
type:"jsonp",
//url: "contacts.json",
url:"http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes",
callbackKey: 'callback',
headers: {
'content-type': 'application/json'
},
reader:{
type:"json",
rootProperty:"contacts"
}

},
autoLoad:true

}
});


The above used web service "http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes" is giving following result in brwoser

(
{
"contacts": [
{
"first_name": "FirstName1",
"last_name": "LastName1"
},
{
"first_name": "FirstName2",
"last_name": "LastName2"
}
]
}
);


But getting the following error in Sencha touch 2 while executing the above code.

Resource interpreted as Script but transferred with MIME type application/octet-stream: "http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes&callback=?&_dc=1342784796368&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1 (http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes&callback=?&_dc=1342784796368&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1)".

Thanks & Regards
Vipin

vipsshan
23 Jul 2012, 1:00 AM
Hi,

How to resolve this type error?. Please help me

Resource interpreted as Script but transferred with MIME type application/octet-stream: "http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes&_dc=1343025403151&page=1&start=0&limit=25&jsoncallback=Ext.data.JsonP.callback1".


Thanks & Regards
Vipin



Hi,
Actually on Sencha site it is written that if you are calling a webservice wich is out side the domain you should use Jsonp, but when I am using it as follows:-
Ext.define("App.store.Contacts", {
extend:"Ext.data.Store",
// requires: [
// "Ext.data.proxy.JsonP"
// ],
config:{
model:"App.model.Contacts",
// autoLoad:true,
sorters:"first_name",
grouper: function(record){
return record.get('first_name')[0];
},
proxy:{
type:"jsonp",
//url: "contacts.json",
url:"http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes",
callbackKey: 'callback',
headers: {
'content-type': 'application/json'
},
reader:{
type:"json",
rootProperty:"contacts"
}

},
autoLoad:true

}
});


The above used web service "http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes" is giving following result in brwoser

(
{
"contacts": [
{
"first_name": "FirstName1",
"last_name": "LastName1"
},
{
"first_name": "FirstName2",
"last_name": "LastName2"
}
]
}
);


But getting the following error in Sencha touch 2 while executing the above code.

Resource interpreted as Script but transferred with MIME type application/octet-stream: "http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes&callback=?&_dc=1342784796368&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1 (http://10.4.3.199/FineDocsMobileServices/Service1.svc/TestSenchaAdd?Dn=yes&callback=?&_dc=1342784796368&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1)".

Thanks & Regards
Vipin