Service call not entering into operationSuccess nor operationFailure

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

Hello team, i am trying to make a service call, but my server is down, as i understand the code for invoving services, when there is no response from server, or when there are any issues regarding the service call, the function operationFailure triggers with the data for the error, but im trying to test what happens when my back end server is down, and my process is just getting frozen in the middle, it doesnt go to operationFailure at all, even after the timeout time has passed

Hi @Joseph Spwingew​ ,

Can you attach the sample code snippet the way you are invoking your services in the application?

function invokeServiceExample(){

serviceName = "SwLogin";

integrationObj = KNYMobileFabric.getIntegrationService(serviceName);

operationName = "OpLogin";

data= {"var_login": login,

"var_clave": clave,

"var_fuente": fuente,

"var_dispositivo": dispositivo};

headers= {};

integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure);

function operationSuccess(res){

kony.print("Respuesta:"+JSON.stringify(res));

if(res.respuesta.codigo == "400"){

Fun_abrirMensaje("Error","Usuario o Clave invalidos.");

}

if(res.respuesta.codigo == "200"){

Fun_DatosUsuario(res);

}

kony.application.dismissLoadingScreen();

}

}

function operationFailure(res){

frmError.show();

frmError.lblError.text = JSON.stringify(res);

kony.print("Falla:"+JSON.stringify(res));

kony.application.dismissLoadingScreen();

}

Input parametersare defined as global variables and are working fine. I have a generic operatin failure function outside beacuse it handles all failures the same way, but all my operation success are defined inside the same function as the sample code show to handle each case

the project is in the traditional architecture model of kony freeform

Can you try placing the operationsuccess and operationfailure before invoking the service since it was declared inside a function it will undefined if you invoke it before init

I tried ding that, and its happening the same way, im not getting undefined error anywhere (which i can get if i just change the function name for testing purposes) it just stays in "listening" mode and i have to mannually kill the app.

It is too weird , Ok lets do some work around

  1. Try implementing the way it was implemented in the example

var integrationClient = null;

var serviceName = <your-service-name>;

var operationName = <your-operation-name>;

var params = { "your-input-keys" : "your-input-values"};

var headers = {"your-header-keys" : "your-header-values"};//If there are no headers,pass null

// options is an optional parameter helps in configuring the network layer.

// To configure for a thin layer, use xmlHttpRequestOptions instead of httpRequestOptions.

// Values for timeoutIntervalForRequest and timeoutIntervalForResource are in seconds.

var options={"httpRequestOptions":{"timeoutIntervalForRequest":60,

"timeoutIntervalForResource":600}}

try{

integrationClient = KNYMobileFabric.getIntegrationService(serviceName);

}

catch(exception){

kony.print("Exception" + exception.message);

}

integrationClient.invokeOperation(operationName, headers, params,

function(result) {

kony.print("Integration Service Response is :" + JSON.stringify(response));

},

function(error) {

kony.print("Integration Service Failure :" + JSON.stringify(error));

}, options

);

make sure you pass null to the header parameter instead of empty

2. if above solution not worked try calling the service as below

var operationName = "<your Operation name>";

inputParams.serviceID = "Service Name";

inputParams.httpheaders = {};

inputParams.httpconfig = {timeout:5};

mfintegrationsecureinvokerasync(inputParams, "Service Name", operationName, callbackMethod);

Either Failure or success it will go to the callback method you have to handle accordingly.