This is a migrated thread and some comments may be shown as answers.

Calling web service in emulator?

13 Answers 147 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jan-Dirk
Top achievements
Rank 1
Jan-Dirk asked on 02 Jul 2012, 09:04 PM
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.

13 Answers, 1 is accepted

Sort by
0
sdobrev
Top achievements
Rank 1
answered on 02 Jul 2012, 11:01 PM
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.
0
Jan-Dirk
Top achievements
Rank 1
answered on 03 Jul 2012, 06:14 AM
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.
0
Jan-Dirk
Top achievements
Rank 1
answered on 04 Jul 2012, 03:00 PM
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.
0
Keen
Top achievements
Rank 1
answered on 25 Mar 2013, 03:19 AM
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 !!
0
Jan-Dirk
Top achievements
Rank 1
answered on 25 Mar 2013, 08:13 AM
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!
0
Keen
Top achievements
Rank 1
answered on 25 Mar 2013, 12:54 PM
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
0
Jan-Dirk
Top achievements
Rank 1
answered on 25 Mar 2013, 12:59 PM
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?
0
Keen
Top achievements
Rank 1
answered on 26 Mar 2013, 01:29 AM
Hi again JD,

    Your code,where will I put that in icenium? in html file?
0
Jan-Dirk
Top achievements
Rank 1
answered on 26 Mar 2013, 12:01 PM
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).
0
Keen
Top achievements
Rank 1
answered on 27 Mar 2013, 03:38 AM
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..
0
Espen Moen Kvelland
Top achievements
Rank 1
answered on 31 Mar 2013, 06:25 PM
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

0
Keen
Top achievements
Rank 1
answered on 11 Apr 2013, 08:31 AM
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
    
0
badal
Top achievements
Rank 1
answered on 07 Jun 2013, 05:35 AM
Hey J-D can you mail me sample application which use W3School temperature web-service??????

p/z Email to blunagariya@gmail.com

asap
Tags
General Discussion
Asked by
Jan-Dirk
Top achievements
Rank 1
Answers by
sdobrev
Top achievements
Rank 1
Jan-Dirk
Top achievements
Rank 1
Keen
Top achievements
Rank 1
Espen Moen Kvelland
Top achievements
Rank 1
badal
Top achievements
Rank 1
Share this question
or