Calling web service in emulator?

14 posts, 0 answers
  1. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 02 Jul 2012 Link to this post

    Should a call to  a web service through XMLHttpRequest(); work in the emulator?

    I have code that worked in Eclypse, but doesn't seem to work in the Icenium emulator.
  2. sdobrev
    sdobrev avatar
    54 posts
    Member since:
    Sep 2012

    Posted 02 Jul 2012 Link to this post

    Hi J.D.,

    Ajax calls should work fine in the simulator. However there is small catch if you are using Mist's simulator. More info here.
  3. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 03 Jul 2012 Link to this post

    Ok, thank you for your quick reply. Maybe it's an issue then with my router that I cannot access my own websites/web services within network.

    For my PC's I can modify the hosts file, but not for the simulator.

    Will check from the office later today.
  4. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 04 Jul 2012 Link to this post

    It worked from PC's outside the network where I have the web services hosted, so the reason that it didn't work is that my router can't handle requests to local addresses correctly.

    Unfortunately, we can't edit the hosts file in the emulators.
  5. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 24 Mar 2013 Link to this post

    J.D can I ask to have example of ur connection string of icenium and web service?
    im doing a project right now. Im new in mobile pass.
    thank you !!
  6. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 25 Mar 2013 Link to this post

    Here is an example of what I use:
    var serverBaseURL = "http://webservices.yourdomain.com/";
    var useURL = "webservice.asmx";
    $.ajax({
        url: serverBaseURL + useUrl,
        dataType: 'jsonp',
        jsonp: 'jsoncallback',
        timeout: 15000,
        success: function(data){
            var recordCount = data.length;
            
            if(recordCount >0) {
                $.each(data, function(index, row) {    
                    // do something
                });
            
            }
        },
        error: function(){
            notify('Connection problem, please try again.', null, 'Server Connection', 'OK');
        }
    });

    Hope it helps!
  7. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 25 Mar 2013 Link to this post

    JD can i hve a favor again?
    Can I request some sample queries? i mean in selecting then putting it to a textbox in icenium.
    Thank you in advance it will be a gud help
  8. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 25 Mar 2013 Link to this post

    It's hard to give a good example because many different results can be returned by a  web service. Do you have an example of the web service you are going to use?
  9. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 25 Mar 2013 Link to this post

    Hi again JD,

        Your code,where will I put that in icenium? in html file?
  10. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 26 Mar 2013 Link to this post

    This may sound harsh, but it is not my intention to sound like that:

    I think that if you don't know where to put the code I posted earlier, then it is to early to ask how to use a webservice...

    The code I posted should be recognized by you as JavaScript and in general we put that in a javascript file (.js).
  11. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 26 Mar 2013 Link to this post

    J-d
        No, its ok..  I get the point. Im so new in mobile apps with web service. Im a Visual Studio trying to learn something new..
  12. Espen Moen Kvelland
    Espen Moen Kvelland avatar
    11 posts
    Member since:
    Jun 2009

    Posted 31 Mar 2013 Link to this post

    Hello, just wanted to see if I could provide you with some examples:

    This is a very simple get request that gets some JSON that I save to the local storage.

    $.get('http://....com/api/apiProject', function(data) {

                localStorage.setItem("nameOfValue", JSON.stringify(data));
        });

    Or using the same example you can populate a listview 

    $.get('http://....com/api/apiProject', function(data) {
    var tmp = '<li><a href=\'ProjectDetails.html?pid=' + project.ProjectID + '\'>' + project.ProjectName + '</a></li>';
                        
    $("#listViewProjects").append(tmp);    
        });

    Here I just add some <li> to an existing listview

  13. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 11 Apr 2013 Link to this post

    JD
        Im, using the northwind database in Catagories and this t he URL
       http://demos.kendoui.com/service/Northwind.svc/Categories
    How can I apply your codes?
    the northwind contains CategoryID and CategoryName. I want to put them in listview using jquery ajax.
    I hope you can help me
        
  14. badal
    badal avatar
    4 posts
    Member since:
    May 2013

    Posted 07 Jun 2013 Link to this post

    Hey J-D can you mail me sample application which use W3School temperature web-service??????

    p/z Email to blunagariya@gmail.com

    asap
Back to Top