Error connecting Icenium to a web service (unauthorized 401)

5 posts, 0 answers
  1. Andres
    Andres avatar
    13 posts
    Member since:
    Aug 2013

    Posted 27 Aug 2013 Link to this post

    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
  2. Markus
    Markus avatar
    205 posts
    Member since:
    Nov 2005

    Posted 28 Aug 2013 Link to this post

    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
  3. Andres
    Andres avatar
    13 posts
    Member since:
    Aug 2013

    Posted 28 Aug 2013 Link to this post

    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
  4. Markus
    Markus avatar
    205 posts
    Member since:
    Nov 2005

    Posted 28 Aug 2013 Link to this post

    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
  5. Andres
    Andres avatar
    13 posts
    Member since:
    Aug 2013

    Posted 28 Aug 2013 Link to this post

    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
Back to Top