IBM Worklight 6.1 - Can a HTTP adapter call anothe

2019-09-04 11:10发布

I am developing app on worklight 6.1 version for iPad and deployed single adapter which is having multiple procedure inside it. Now I am hitting adapter from client-side and getting response from server. Storing that response somewhere and passing back to the next adapter call for getting related data for that response.

function GetUSERRID(){
    var invocationData = {
            adapter : 'CORE_ADAPTER',
            procedure : 'GetUserRID',
            parameters : [ param1, param2 ]
        };

    WL.Client.invokeProcedure(invocationData,{
        onSuccess : GetUserRID,
        onFailure : function GetUserRIDFailure(response){ busyInd.hide();console.log("reponse   failure  "+response);},
    });

}

function GetUserRID(response){
    var rid = response.invocationResult.RID;
    var invocationData = {
            adapter : 'CORE_ADAPTER',
            procedure : 'GetUserRID_Details',
            parameters : [ rid ]
        };

    WL.Client.invokeProcedure(invocationData,{
        onSuccess : ShowDetailsForRID,
        onFailure : function GetUserRID_DetailsFailure(response){ busyInd.hide();console.log("reponse   failure  "+response);},
    });
}  

In the above code I am making two adapter calls from client. From the first I am getting some data which I am again passing back to next adapter for getting related data.

Can I make a single adapter call on server and that adapter will call another adapter on server with required data as a parameter from first adapter response and process it and return data back to client?

2条回答
相关推荐>>
2楼-- · 2019-09-04 11:38

Same as client side just use

WL.Server.invokeProcedure(invocationData,options);

var invocationData = {
        adapter : 'ADAPTER_NAME',
        procedure : 'PROCEDURE_NAME',
        parameters : [param1,param2]
    };

WL.Server.invokeProcedure(invocationData,{
    onSuccess : getDataSuccess,
    onFailure : getDataFailure,
});
查看更多
冷血范
3楼-- · 2019-09-04 11:41

You need to read the "Advanced adapter usage and mashup" training module, which talks exactly about how to "chain adapter invocations".

An example project is available as well in the link above.

查看更多
登录 后发表回答