Topic
  • 10 replies
  • Latest Post - ‏2012-12-06T01:55:37Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts

Pinned topic How to call HTTPAdapter

‏2012-12-05T08:19:44Z |
I created a HTTPAdapter, my HTTPAdapter.js inside method is getQuestionDocument1 (year), use
the Invoke Worklight Procedure test success and return to test data are as follows:
{
"getQuestionDocument1Response": {
"ns1": "http:\/\/Performance\/MathService",
"out": "2012"
},
"isSuccessful": true
}
In my worklight project call this method and use return data should be how to do?
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T08:28:53Z  
    @liviowm

    function getQuestionDocument(result) {
    if (result.invocationResult.isSuccessful) {
    var ns1= result.invocationResult.getQuestionDocument1Response.ns1;
    console.log("value of ns1 :"+ns1);
    }
    }
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T08:42:01Z  
    @liviowm

    function getQuestionDocument(result) {
    if (result.invocationResult.isSuccessful) {
    var ns1= result.invocationResult.getQuestionDocument1Response.ns1;
    console.log("value of ns1 :"+ns1);
    }
    }
    @PraveenBabu

    thanks , I am in my worklight inside the js created the following method,But no effect, I write wrong?

    function btnAjaxPost() {
    // busyIndicator.show();
    var invocationData = {
    adapter : 'HTTPAdapter',
    procedure : 'getQuestionDocument1',
    parameters : 20111

    };

    WL.Client.invokeProcedure(invocationData, {
    onSuccess : btnAjaxPostgood,
    onFailure : getCitiesListFailure
    });
    }
    function btnAjaxPostgood(response) {

    alert(response.invocationResult.getQuestionDocument1Response.ns1);

    }
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T08:47:50Z  
    @PraveenBabu

    thanks , I am in my worklight inside the js created the following method,But no effect, I write wrong?

    function btnAjaxPost() {
    // busyIndicator.show();
    var invocationData = {
    adapter : 'HTTPAdapter',
    procedure : 'getQuestionDocument1',
    parameters : 20111

    };

    WL.Client.invokeProcedure(invocationData, {
    onSuccess : btnAjaxPostgood,
    onFailure : getCitiesListFailure
    });
    }
    function btnAjaxPostgood(response) {

    alert(response.invocationResult.getQuestionDocument1Response.ns1);

    }
    small change in ur code..

    function btnAjaxPostgood(response) {
    bolean res=response.invocationResult.isSuccessful; // Result return boolean type.. basis on that it will enter
    if (response.invocationResult.isSuccessful) { // this is necessary
    alert("Entered if the result is successful"); // check this condition...
    var ns1=response.invocationResult.ns1;
    var ns2=response.invocationResult.getQuestionDocument1Response.ns1;
    console(ns1+" "+ns2); check this also.
    }
    }
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T08:51:46Z  
    small change in ur code..

    function btnAjaxPostgood(response) {
    bolean res=response.invocationResult.isSuccessful; // Result return boolean type.. basis on that it will enter
    if (response.invocationResult.isSuccessful) { // this is necessary
    alert("Entered if the result is successful"); // check this condition...
    var ns1=response.invocationResult.ns1;
    var ns2=response.invocationResult.getQuestionDocument1Response.ns1;
    console(ns1+" "+ns2); check this also.
    }
    }
    this was my code structure it works fine..
    var invocationData = {
    adapter : 'testhttpadapter',
    procedure : 'testprocedure',
    parameters : empid, fromdate, todate, days, reason, 0
    };

    var options = {
    onSuccess : empApplyLeaveSuccess,
    onFailure : empApplyLeaveFailure,
    };
    WL.Client.invokeProcedure(invocationData, options);
    }

    function empApplyLeaveSuccess(result) {

    }
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T09:53:52Z  
    this was my code structure it works fine..
    var invocationData = {
    adapter : 'testhttpadapter',
    procedure : 'testprocedure',
    parameters : empid, fromdate, todate, days, reason, 0
    };

    var options = {
    onSuccess : empApplyLeaveSuccess,
    onFailure : empApplyLeaveFailure,
    };
    WL.Client.invokeProcedure(invocationData, options);
    }

    function empApplyLeaveSuccess(result) {

    }
    this was my code :

    function btnAjaxPost() {
    // busyIndicator.show();
    var invocationData = {
    adapter : 'HTTPAdapter',
    procedure : 'getQuestionDocument1',
    parameters : 2012
    };

    var options = {
    onSuccess : btnAjaxPostgood,
    onFailure : getCitiesListFailure,
    };
    WL.Client.invokeProcedure(invocationData, options);
    }

    function btnAjaxPostgood(result) {

    var res = result.invocationResult.isSuccessful;

    if (result.invocationResult.isSuccessful) {

    alert("Entered if the result is successful");
    var ns1 = result.invocationResult.ns1;
    var ns2 = result.invocationResult.getQuestionDocument1Response.ns1;
    alert(ns1 + " " + ns2);

    } else {

    alert(res);
    }

    }

    error:

    Invalid invocation of method WL.Client.invokeProcedure; Invalid options attribute 'parameters' . Invalid invocation of method WL.Client.invokeProcedure; Invalid value '2012'(number),expected type 'object'.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T16:03:45Z  
    this was my code :

    function btnAjaxPost() {
    // busyIndicator.show();
    var invocationData = {
    adapter : 'HTTPAdapter',
    procedure : 'getQuestionDocument1',
    parameters : 2012
    };

    var options = {
    onSuccess : btnAjaxPostgood,
    onFailure : getCitiesListFailure,
    };
    WL.Client.invokeProcedure(invocationData, options);
    }

    function btnAjaxPostgood(result) {

    var res = result.invocationResult.isSuccessful;

    if (result.invocationResult.isSuccessful) {

    alert("Entered if the result is successful");
    var ns1 = result.invocationResult.ns1;
    var ns2 = result.invocationResult.getQuestionDocument1Response.ns1;
    alert(ns1 + " " + ns2);

    } else {

    alert(res);
    }

    }

    error:

    Invalid invocation of method WL.Client.invokeProcedure; Invalid options attribute 'parameters' . Invalid invocation of method WL.Client.invokeProcedure; Invalid value '2012'(number),expected type 'object'.
    Please follow this code structure.. and call js file in html page..
    var invocationData = {
    adapter : 'testhttpadapter',
    procedure : 'testprocedure',
    parameters : empid, fromdate, todate, days, reason, 0
    };

    var options = {
    onSuccess : empApplyLeaveSuccess,
    onFailure : empApplyLeaveFailure,
    };
    WL.Client.invokeProcedure(invocationData, options);
    }

    function empApplyLeaveSuccess(result) {

    }
  • DG1M_Harry_Ho
    DG1M_Harry_Ho
    49 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T16:19:24Z  
    this was my code :

    function btnAjaxPost() {
    // busyIndicator.show();
    var invocationData = {
    adapter : 'HTTPAdapter',
    procedure : 'getQuestionDocument1',
    parameters : 2012
    };

    var options = {
    onSuccess : btnAjaxPostgood,
    onFailure : getCitiesListFailure,
    };
    WL.Client.invokeProcedure(invocationData, options);
    }

    function btnAjaxPostgood(result) {

    var res = result.invocationResult.isSuccessful;

    if (result.invocationResult.isSuccessful) {

    alert("Entered if the result is successful");
    var ns1 = result.invocationResult.ns1;
    var ns2 = result.invocationResult.getQuestionDocument1Response.ns1;
    alert(ns1 + " " + ns2);

    } else {

    alert(res);
    }

    }

    error:

    Invalid invocation of method WL.Client.invokeProcedure; Invalid options attribute 'parameters' . Invalid invocation of method WL.Client.invokeProcedure; Invalid value '2012'(number),expected type 'object'.
    Try '2012'.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T16:46:48Z  
    Try '2012'.
    parameters needs to be an array.

    parameters: 2012

    or

    parameters:

    (depending on whether you are using 2012 as a number or a string)
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-05T16:48:54Z  
    parameters needs to be an array.

    parameters: 2012

    or

    parameters:

    (depending on whether you are using 2012 as a number or a string)
    hmmm... The blog ate my square braces.

    parameters need to be enclosed in square braces to indicate that it is an array.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to call HTTPAdapter

    ‏2012-12-06T01:55:37Z  
    hmmm... The blog ate my square braces.

    parameters need to be enclosed in square braces to indicate that it is an array.
    Thank you very much, according to your method I call a success