Calling an existing OFBiz Service from another OFBiz method is very simple.
Prepare any necessary context parameters. To call an OFBiz Service, you may need to pass one or more parameters (called "IN" or "INOUT" parameters) using a Java Map structure. Consult the WebTools Service List for more information on any particular Service’s required and optional input and/or output parameters.
The following code snippet highlights the necessary Java code to call Services synchronously, asynchronously, and as scheduled processes:
Note: Only enough code necessary to illustrate Service invocation is shown.
import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ServiceUtil; // For an OFBiz Service, get the service dispatcher as follows LocalDispatcher dispatcher = dctx.getDispatcher(); // For an OFBiz Event, get the service dispatcher...