1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    2
    Vote Rating
    0
    Tejendra is on a distinguished road

      0  

    Default How can I access webservice using sencha touch2?

    How can I access webservice using sencha touch2?


    I have created "Hello World" webservice, I am trying to access webservice using Sencha touch2 and SDK. but it didn't show any output as well as error. I have used below code in App.js file.

    Ext.Ajax.request({
    url: 'http://localhost:3661/Service1.asmx?op=HelloWorld',
    success: function(response) {
    console.log("Success" + msg)
    },
    failure: function (msg) {
    console.log("Failure" + msg)
    }
    });

    when I tried to browse index.html page it didn't show me the output. can someone please guide me?
    Last edited by Tejendra; 30 Apr 2012 at 1:12 AM. Reason: Spell correction

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,329
    Vote Rating
    847
    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


    Any errors like cross-origin blocking?
    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.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    2
    Vote Rating
    0
    Tejendra is on a distinguished road

      0  

    Default


    Hi,

    Thanks for looking into this. No Error like cross-origin blocking. I have writen new code to call WCF service in app.js file as below :

    Ext.Ajax.request({
    url: 'http://localhost:2908/Service1.svc/',
    method: 'get',
    params: {value: 10},
    callback: function(response, opts) {
    console.log(response.responseText);
    },
    jsonData: { "Alert": {} },
    headers: { 'Content-Type text/xml': 'application/json;charset=utf-8' },
    success: function (response, opts) {
    alert(response.responseText);
    alert("Hi")
    }
    })


    Now when I ran index.html file in crome browser it call's the service but does not return any output. when I press F12 it shows me below error :

    " XMLHttpRequest cannot load http://localhost:2908/Service1.svc/?...18856&value=10. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
    app.js:6undefined"

    Is it beacause of I am using ajax request to call WCF service? Do I need to use JSONP ?
    I have tried to call wcf service using Jquery but looks like syntaxes of jquery not supported in app.js file.. can you please guide me?
    Thanks,
    Tejendra

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,329
    Vote Rating
    847
    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


    So you are getting a cross-origin block error. YOu need to do one of two things, enable CORS on the server or use JsonP
    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