Create Custom Java Web Service

The following steps discuss how a new Java-based Web Service is created:

  1. Go to Project Tree, right-click Web Services > New Web Service to display the Function Editor window.

    drawing

  2. Click either the Objects or Database tab (left pane) and then either > DB Interface, Newest Reference File or Newest LU File.

  3. Select the preferred DB Connection. To access Fabric, select Newest LU Name. Note that for the newest file of an LU to be a part of the DB Connections list, at least one LUI must be executed using the Data Viewer.

  4. Click the DB File icon to display the Logical Unit Tables list.

    drawing

  5. Click the table that retrieves the data, check the Columns list and right-click the column that is the Input parameter for data retrieval.

  6. Click Add Selected to Input Parameters.

    drawing

    Note that the Column Name, Data Type, Mandatory and Comments are displayed in the Input Parameters list in the lower right pane.

  7. Select the Column/s to be retrieved or press the CTRL key to select multiple columns. Right-click and select Generate Code to automatically create the Select Statement and Basic Code Structure.

The generated code is displayed in the Java Editor window and includes the basic structure of the call to the interface or LUDB and the Fetch method. Note that you can also write your own code.

drawing

  1. Once the code is generated, edit the function based on the logic to be applied. For example:
       Db.Rows rows = ludb("Customer", <instanceID>).fetch(sql, <val1>, <val2>, ...);
       Replace the <instanceID> placeholder with the input parameter CUSTOMER_ID.
       Db.Rows rows = ludb("Customer", CUSTOMER_ID).fetch(sql);
  1. Set the Web Service Properties in the right pane.

  1. In Fabric top menu bar - choose New Web Service > New Java Web Service.

    drawing

  2. In the pop-up input box, at the top of the screen, either select a category from the list or choose to create a new one.

  3. In the next pop-up input box - fill in the name for the web service.

  4. The Logic Java file will then be opened and populated with the default template skeleton of a web service function.

@desc("")
@webService(path = "", verb = {MethodType.GET, MethodType.POST}, version = "1", isRaw = false, isCustomPayload = false, produce = {Produce.XML, Produce.JSON}, elevatedPermission = false)
@resultMetaData(mediaType = Produce.JSON, example = "")
public static void webServiceName(@param(description="") String param1) throws Exception {
}
  1. Write your web service logic in the Java Editor.
  2. Set the Web Service Properties by changing the function annotations.

Note that you can add Web Services functions by pressing CTRL -> SPACE and selecting the requested snippet (tip: start typing fabric to reveal the required one - "fabric-function-ws").

Previous

Create Custom Java Web Service

The following steps discuss how a new Java-based Web Service is created:

  1. Go to Project Tree, right-click Web Services > New Web Service to display the Function Editor window.

    drawing

  2. Click either the Objects or Database tab (left pane) and then either > DB Interface, Newest Reference File or Newest LU File.

  3. Select the preferred DB Connection. To access Fabric, select Newest LU Name. Note that for the newest file of an LU to be a part of the DB Connections list, at least one LUI must be executed using the Data Viewer.

  4. Click the DB File icon to display the Logical Unit Tables list.

    drawing

  5. Click the table that retrieves the data, check the Columns list and right-click the column that is the Input parameter for data retrieval.

  6. Click Add Selected to Input Parameters.

    drawing

    Note that the Column Name, Data Type, Mandatory and Comments are displayed in the Input Parameters list in the lower right pane.

  7. Select the Column/s to be retrieved or press the CTRL key to select multiple columns. Right-click and select Generate Code to automatically create the Select Statement and Basic Code Structure.

The generated code is displayed in the Java Editor window and includes the basic structure of the call to the interface or LUDB and the Fetch method. Note that you can also write your own code.

drawing

  1. Once the code is generated, edit the function based on the logic to be applied. For example:
       Db.Rows rows = ludb("Customer", <instanceID>).fetch(sql, <val1>, <val2>, ...);
       Replace the <instanceID> placeholder with the input parameter CUSTOMER_ID.
       Db.Rows rows = ludb("Customer", CUSTOMER_ID).fetch(sql);
  1. Set the Web Service Properties in the right pane.

  1. In Fabric top menu bar - choose New Web Service > New Java Web Service.

    drawing

  2. In the pop-up input box, at the top of the screen, either select a category from the list or choose to create a new one.

  3. In the next pop-up input box - fill in the name for the web service.

  4. The Logic Java file will then be opened and populated with the default template skeleton of a web service function.

@desc("")
@webService(path = "", verb = {MethodType.GET, MethodType.POST}, version = "1", isRaw = false, isCustomPayload = false, produce = {Produce.XML, Produce.JSON}, elevatedPermission = false)
@resultMetaData(mediaType = Produce.JSON, example = "")
public static void webServiceName(@param(description="") String param1) throws Exception {
}
  1. Write your web service logic in the Java Editor.
  2. Set the Web Service Properties by changing the function annotations.

Note that you can add Web Services functions by pressing CTRL -> SPACE and selecting the requested snippet (tip: start typing fabric to reveal the required one - "fabric-function-ws").

Previous