Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Documented entity-auto

...

Above you can see the name of this service is userLogin and it uses the java engine. This service expects two required IN parameters: login.username and login.password. Required parameters are tested before the service is invoked. If the parameters does not match by name and object type the service is not invoked. Parameters which may or may not be sent to the service should be defined as optional. After the service is invoked, the OUT parameters are tested. Only required parameters are tested, however if a parameter is passed which is not defined as optional or required it will cause the service to fail. This service has not required OUT parameters, so the result is simply returned.

...

Automatic Entity Maintenance Service Definition

OFBiz can automatically define services for simple Create, Update and Delete (CrUD) operations for many entities.

Set the engine attribute to "entity-auto" and the invoke attribute to "create", "update", or "delete". 

For example:

Code Block
languagexml
<service name="createInvoiceContactMech" engine="entity-auto" invoke="create" default-entity-name="InvoiceContactMech">
    <description>Create a ContactMech for an invoice</description>
    <permission-service service-name="acctgInvoicePermissionCheck" main-action="CREATE"/>
    <auto-attributes include="pk" mode="IN" optional="false"/>
</service>

 

The entity-auto engine can implement the following Create operations:

  1. a single OUT primary key for primary auto-sequencing
  2. a single INOUT primary key for primary auto-sequencing with optional override
  3. a multi-part primary key with all parts part IN except the last which is OUT only (the missing primary key is a sub-sequence mainly for entity association
  4. all primary key fields IN for a manually specified primary key

For any more complex situation, write code for your own service instead of relying on an automatically defined one.

Usage

Anchor
usage
usage

...

Internal Usage of the Services Framework is quite simple. In a Web Application the LocalDispatcher is stored in the ServletContext which can be accessed via the Session object in an Event. For non-web based applications you simply create a GenericDispatcher: GenericDelegator delegator = GenericDelegator.getGenericDelegator("default");
LocalDispatcher dispatcher = new GenericDispatcher("UniqueName",delegator);
Now we have a dispatcher which we can use to invoke services. To invoke the test service create a Map for the context which contains the IN parameter message *then invoke the service:*

...