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

Error connecting Icenium to a web service (unauthorized 401)

4 Answers 65 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.
Andres
Top achievements
Rank 1
Andres asked on 27 Aug 2013, 04:58 PM
Hi,

We have a problem when we try to call a web service by JQuery ajax method from a Icenium development. We get a 401 (Unauthorized) error when we make the call to the method of the service.

Is very strange because the same code is working fine in Chrome or Firefox, but in Graphite simulator or in the device (with Android) only works sometimes, and when it works, is only for a few minutes, then we got the same error again and again, even without making any change.

We are using jsonp to avoid the cross-domain issue, and we also add to the response header Access-Control-Allow-Origin = "*" for cross-origin problems.

We tried to conect using the asmx service and also with the WCF service, and the same problem is found


Here is the code:

function testjsonp() {
        $.ajax({
            data: { email: JSON.stringify('anemail@aa.com'), password: JSON.stringify('password')},
            dataType: "jsonp",
            type: "GET",
            contentType: "application/json; charset=utf-8",
            async: false,
            success: function (data) {
                alert(data.d);
            },
            error: function (data) {
                $('#div_error').html(data.responseText);
            }
        });
    } 


We appreciate a lot any help, we are really stack after many tests and many hours googling...

Thanks a lot

Andres & Rodrigo

4 Answers, 1 is accepted

Sort by
0
Markus
Top achievements
Rank 2
answered on 28 Aug 2013, 07:29 AM
Dear Andres

This might be a wild shot. But if you access an SQL Database for example to get data then there might be a firewall rule that does not allow you to access it from external sources.

So when you run it on the webserver that might be fine to access the SQL server on the same machine - but if you access it from your mobile then thats another thing.

Lucky shoot - but if you have been googling a lot an pulling your hair, any new idea might be welcome :-)

Markus
0
Andres
Top achievements
Rank 1
answered on 28 Aug 2013, 07:42 AM
Thanks for your reply, I wondered that this fact  is solved with the cross-domain issue, allowing the Access-Control-Allow-Origin = "*" .

I will check in that direction anyway, because might be we are missing something.

Cheers,
Andres
0
Markus
Top achievements
Rank 2
answered on 28 Aug 2013, 08:13 AM
Dear Andres

I am talking about the windows firewall (if you are using windows) that might restrict access to the sql port from outside.

Markus
0
Andres
Top achievements
Rank 1
answered on 28 Aug 2013, 09:11 AM
Ah yes, we have controlled the firewall.

We have just seen that the problem seems to be related with the cookies. It looks like they are expiring after a few seconds... 

Thanks anyway
Tags
General Discussion
Asked by
Andres
Top achievements
Rank 1
Answers by
Markus
Top achievements
Rank 2
Andres
Top achievements
Rank 1
Share this question
or