Runtime tools : Channels components : Mobile Channel : Tasks : Invoking server operation
  
Invoking server operation
After establishing session with the server side, eRCP application can invoke server side operation and get the synchronized result.
There are two ways to invoke the server side operation:
Basic way to invoke the server side operation
You can adopt the basic way if the input and output of server operations are the same JavaBean, and there is only one input for server operation.
Following is an example scenario of how you can get detailed customer information from CustomerID using the same input and output JavaBean:
Customer information is maintained by a JavaBean named Customer, which has several attributes: CustomerID, Address, Age, and so on. In eRCP client, you can initialize JavaBean Customer with attribute CustomerID and leave the other attributes as null, and then pass the operation name and JavaBean to the server side. Server side operation retrieves customer information based on CustomerID, and fills the other attributes back to JavaBean Customer (such as Address, and Age). In this case the input JavaBean and output JavaBean are the same. They are JavaBean Customer.
The detailed method is as follows:
/**
* Invoke server side operation and return the processing result If the
* passed java bean and returned result are the same, use this API to invoke
* server side operation. In BTT C/S client mechanism, one is passing the
* java bean to the server side, setting the values of this java bean in the
* server side operation and returning this processed java bean to client
* side. This method is implemented for this usage. Please establishSession
* before invoking this API.
*
* @param operationName
* @param param
* the Serializable JavaBean passed to server side
* @return the processed JavaBean
* @throws Exception
* if error occurs
*/
public Serializable invoke(String operationName, Serializable param) throws Exception
Advanced way to invoke server operation
You can adopt the advanced way if the input and output of server operations are different or there are more than one parameter is necessary for the operation input
In the advanced way to invoke server operation, Map is used to pass input of server operation. You can put JavaBean object and other simple attributes into Map. For those maps, key is the data ID which is defined in the context of the server operation. Value is the input JavaBean and other attributes. Response data ID is the ID of output JavaBean and is defined in the context of server operation. The UNICOM® Digital Transformation Toolkit (UDTT™) server returns the serialized JavaBean which has the name of the specified ID in the operation context.
The detailed method is as follows:
/**
* Invoke server side operation and return the processing result.
* If the passed java bean and returned result are different or you need to pass more
than one parameters,
* use this API to invoke server side operation.
* This method is generic, it supports below usage scenarios:
* 1) passing one java bean or more than one java bean to the server side and returning
the result
* Sample Code:
* User user = new User();
user.setUserName("aaaa");
user.setPassword("bbbb");

Map param = new HashMap();
param.put("userBean", user); // the key is the data id defined in the server side
context definition
Result result = (Result) adapter.invoke("MobileSignInOp", param, "resultBean");

2) passing the query conditions to the server side and returning the result
Sample Code: Query user by userId:
Map newParam = new HashMap();
newParam.put("userId", "123456"); // the userId defined in the server side context
definition
User newResult = (User) adapter.invoke("MobileQueryUserOp", newParam, "userBean");
3) You can mix the first two usages.
User user = new User();
user.setUserName("aaaa");
user.setPassword("bbbb");

Map param = new HashMap();
param.put("userBean", user); // the key is the data id defined in the server side
context definition
param.put("firstLogin","true");// the key is the data id defined in the server side
context definition
Result result = (Result) adapter.invoke("MobileSignInOp", param, "resultBean");
*
* @param operationName the operation name
* @param param The Map contains the JavaBean or Simple Java Object passed to the server side.
* The key is the data id defined in the server side operation context definition
* @param responseDataId the response data id defined in the server side operation context
*
* @return the processed JavaBean
* @throws Exception if error occurs
*/
public Serializable invoke(String operationName, Map param, String responseDataId)
See
Invoking session operation using the basic way
Invoking session operation using the advanced way
Go up to
Tasks