问题
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?
回答1:
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.
回答2:
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,
});
来源:https://stackoverflow.com/questions/20838582/ibm-worklight-6-1-can-a-http-adapter-call-another-http-adapter-on-server-side