Services within AWE are useful to execute any kind of bussiness logic on the server side. It can execute
C code to do whatever task we want to.
Services are a kind of action, exposed on the client side as actions of type
server where the query or maintain to be executed comes along with the
service attribute (for queries) or
<serve> element (for maintains).
The service engine is the one who redirects to the appropiate engine depending on the action type (data or maintain) as well as the service type (Java, C web services, message queues, ...)
For the service definition it is necessary to specify in
global/services.xml file. The complete list of elements and attributes for services can be found in wiki🔗.
Java services are those used for Java code execution as Spring Beans. We can execute functions from the project as well as third party APIs. The only condition is that the java class has to be loaded in the
classpath and has
@Service annotation .
The specific attributes for Java services are documented here🔗.
- Example: To help to understand this tutorial we are going to develop a simple Java service where we will execute a method from one of our classes to fill in a criterion. The method will receive 2 parameters and will return as the result its concatenation.
To develop the Java service with AWE it will be necessary to specify in
services.xml the structure of the service.
As you can see, our service has and identifier (
MyJavaService). We told it to execute the method
concat defined in class
MyService whose complete path in classpath is
com.app.services.MyService. Also, we have specified that this method will receive two parameters of type String called
Once the service is defined in the xml, we have to create the bean component class and method to execute. For this, it is recommended to have a logic layer as a controller and from there call the method we want to execute defined in the manager. This way, we can modify the controller layer without impacting the bussiness logic from the manager, making the code more maintainable.
Following this recommendation, we are going to create the Servicios class as a controller.
IMPORTANT: This class may extend
ServiceConfigclass to be able to access the context of the application.
IMPORTANT: As can be seen, a method that receives two strings and returns a
ServiceDataobject has been defined. All services must return this AWE object. This object, among other things, has the
Datalistproperty where all the data to be returned is stored.
As we can see, the method
concat returns the object
ServiceData with the result of the concatenation of two parameters. In this example, the information to be returned was done by creating an array two elements long (label and value) that have the same value.
Note: This would be one of the many way to return information in AWE. Another way could be creating a
Datalistobject with the information relative to rows and columns and adding it to the
ServiceDataobject that must be returned.
Web services are a kind of special service used to invoke
C functions throught the web service provided by the ALU (ALmis Utilities) library.
The specific attributes for the Web ALU services are documented here🔗.
- Example: As we did with Java services, we are going to develop a C service that concatenates two Strings to fill in a criterion.
The first thing we have to do is define the structure of the service inside of the
services.xml file within the
global folder, stating that it will be a web service (
As in the previous service, we have given an identifier name
ConcatString. With the
<web /> tag, we are specifying the type of service we are talking about.
In web service is necessary to indicate the name that will match the identifier defined in
services.xml for this web service inside of folder
webservices. It is important to point out that we have set the type attribute to
DATA so we know that the service is going to return some (in this case, the string concatenation).
This file will hold the proper definition of the web service. This file is used by the engine to convert the parameters and be able to build the SOAP request to the web service.
Note: it is important to note that the
nameattribute from the service element must have the same value as the
nameattribute of the service defined in
services.xmlin global folder. The
callattribute indicates the name of the function to be called in C (will be sent as a parameter).
Interface of service in
Finally, we hace to define the functionality of the actual web service. For this, the file
xxxWbsFcn.c has been created as a template.
Important: Do not forget to create the header file