Search code examples
javascriptweb-servicestemenos-quantum

what does opcode==0 signify?


I am using Kony studio for an app development. I have done the login validation using Eclipse to code for creating web services to connect to the oracle10g database. But on the front end I'm getting an error, when I'm trying to connect the front end to the web service. The status==400 is getting validated but I'm not getting opcode as 0, instead its going in the else statement and giving an error alert. This is the Javascript code for connecting to the web service. Please help. What does opstatus==0 signify?

function GetLogin()
{



var Userid =login.txtloginuname.text;
var Password = login.txtloginpass.text;

var inputParamsLogin={serviceID:"servicelogin",uname:Userid,pass:Password}


if (Userid!=null && Userid!="" && Password!="" && Password!=null)
  {

  appmiddlewareinvokerasync(inputParamsLogin,loginCallBackresponse);
  }
  else
  {
        var alert_seq5_act0 = kony.ui.Alert(
              {
            "message": "Please Enter User name and password",
            "alertType": constants.ALERT_TYPE_ERROR,
            "alertTitle": "",
            "yesLabel": "OK",
            "noLabel": "",
            "alertIcon": "",
            "alertHandler": null
        }, {});
        kony.application.dismissLoadingScreen();
   }

function loginCallBackresponse(status,loginResults)
{
        if(status==400)
        {
        alert("productResults");
            if(loginResults.opstatus==0)
            {
             alert("inside opstatus");

            else
            {
            var alert_seq5_act0 = kony.ui.Alert({"message": "Service      Failed:"+loginResults.errmsg,
            "alertType": constants.ALERT_TYPE_ERROR,
            "alertTitle": "",
            "yesLabel": "OK",
            "noLabel": "",
            "alertIcon": "",
            "alertHandler": null}, {});
            kony.application.dismissLoadingScreen();
            }
         }
       }
     }

I am getting the alert "product results" but unable to get the alert "inside opstatus". Instead I'm getting "service failed alert.


Solution

  • If the opstatus is 0, it indicates that the service call is a success while a non-zero value indicates a failure.

    Please read the following that gives you more info on network call in Kony

    The following is the description of the parameters associated with network call in kony:

    status - an integer value - indicating the status

    The following are the various status returned:

    100 - network call initiated successfully - resultset will not be available and it is nil.
    200 - network is in progress (when you start receiving the 1st byte) - resultset will not be available and it is nil.
    300 - network call canceled - resultset will not be available and it is nil.
    400 - network call is finished (gets called in both success and failure scenarios - actual state can be queried using opstatus in the resultset.
    Note: On Mobile Web, the callback function is always invoked with a status of 400. Other intermediate status codes are not applicable on Mobile Web.

    resulttable - a Object with key-value pairs - follows the same structure (opstatus, errcode, errmsg along with the actual network returned data)
    This represents the Object returned by the service. This Object contains three values:

    opstatus

    errcode

    errmsg.

    If the opstatus is 0, it indicates that the service call is a success while a non-zero value indicates a failure.

    If the opstatus is a non-zero value, it is captured in errcode. The following are the possible error codes:

    1000- Unknown Error while connecting (If the platform cannot differentiate between the various kinds of network errors, the platform reports this error code by default).
    1011 - Device has no WIFI or mobile connectivity. Please try the operation after establishing connectivity.
    1012 - Request Failed.
    1013 - Middleware returned invalid JSON string.
    1014 - Request timed out.
    1015 - Cannot find host.
    1016 - Cannot connect to host.
    1200 - SSL - Certificate related error codes.
    The error message corresponding to each error code is captured in the errmsg parameter.