Docs Menu
User Guide / Service / Java

Java Service

Java Service is needed when there exists a need to create a web service that is difficult to build in the API service setup. A Java Service can be called directly from the API service. A Java service can invoke a Java application. It uses a JAR file from the library and inside this JAR file, multiple classes are stored that use Java Library for execution. There are two main reasons for using a Java Service.

1. Implement Custom Algorithms

Sometimes the programming logic is a bit complex and there is a need for creating a custom logic that is not possible or not supported in the API service. In that case, a customized Java Service is created by writing a suitable Java code and then calling the same through a API service.

2. Communicate with Java Library

Communicating directly with the Java Library through a API service is not supported by the Syncloop platform. So as to implement the communication with Java Library or use any existing Java Code is implemented by writing Java Service and calling the same in the API service.

To create a Java Service on the Syncloop Platform Right-Click on the Package Folder then select New 🡪 Services 🡪 Java

Root Properties

Note:

i) A Java Service cannot invoke or call any other Java Service.
ii) A Java Service cannot invoke or call any other API service.

Code Window

A code window is a window where actual Java code is written. A Java Service will be created with a default code already written. After writing the code if the code is saved by clicking on the save button the syntax of the Java Code is correct.

Root Properties

The above Java Service code format will remain the same and should not be changed.

The various windows available on Syncloop API Development Platform are the same as are for the API service. The input/output parameters support all those data types that are also available in the API service. Here these variables are given as input to the Java Code where they are processed and output is derived from the Java service code and stored in the output parameters of the API service.

To get the data in the Java Service code DataPipeline Object is used. This object is the main object for getting the data from the input parameters and saving the output in the output parameters. These input and output parameters can be mapped while calling this Java Service in the API service. In addition to that the DataPipleline object has many other methods and properties for handling various data types and variable arrays.

Example for getting input parameters

dataPipline.getString(“ ”); // This recommended
dataPipline.getAsString(“ ”);
like that we can implement it for other datatypes. To implement the object for arrays the method that is used is
dataPipline.get(“ ”);

Example for putting output parameters

dataPipline.putString(“ ”); // This recommended
dataPipline.putAsString(“ ”);
like that we can implement it for other datatypes. To implement the object for arrays the method that is used is
dataPipline.put(“, );

Mapping the parameters

When the Java Service is called into the API Service the input and output parameters of the Java Services can be mapped with the input and output parameters of the API service. This can enable the usage of various methods defined in Java Service to be used in the API Service. This also enables a developer to efficiently use the Java library by a API service indirectly through a Java Service.