The following Java code snippet demonstrates first retrieving two request parameters (param1
and param2
) from the context
Map passed to every OFBiz Service. Note that all request parameters start out life as strings of characters. The OFBiz Service engine will automatically convert request values to the appropriate type based on Service definition configuration.
The following code shows you how to retrieve parameters:
import java.util.*; import org.ofbiz.service.ServiceUtil; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilValidate
public static Map myService(DispatchContext dctx, Map context){
// Some code here
// First, just get a request parameter from the context
// Note: this must already be configured as part of the
// Service definitions INPUT parameters
String param1 = (String) context.get("param1");
Integer param2 = (Integer) context.get("param2);
// You may use the UtilValidate methods to validate...