Creating a Web Service

An exposed Fabric Web Service enables you to access specific data attributes stored in Fabric using input parameter/s and the relevant structured response like JSON, XML or CSV.

Fabric Studio supports defining a Web Service function, saving it to the project file and deploying it to the Fabric Server. A Web Service is a Java function.

How Do I Create a New Web Service?

The following steps discuss how a new Web Service is created and include options for generating parts of code automatically:

  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 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

  8. 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);

  9. Set the Web Service Properties in the upper right corner pane.

  1. Go to Project Tree > Web Services and right-click Java to select New Java File.

    drawing

  2. Fill in the name for the web service in the pop-up input box at the top of the screen

    drawing

  3. Start writing your code in the Java editor, using VScode built-in code snipplets by pressing CTRL -> SPACE and selecting the requested snipplet

   @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 {
   }

Previous

Creating a Web Service

An exposed Fabric Web Service enables you to access specific data attributes stored in Fabric using input parameter/s and the relevant structured response like JSON, XML or CSV.

Fabric Studio supports defining a Web Service function, saving it to the project file and deploying it to the Fabric Server. A Web Service is a Java function.

How Do I Create a New Web Service?

The following steps discuss how a new Web Service is created and include options for generating parts of code automatically:

  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 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

  8. 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);

  9. Set the Web Service Properties in the upper right corner pane.

  1. Go to Project Tree > Web Services and right-click Java to select New Java File.

    drawing

  2. Fill in the name for the web service in the pop-up input box at the top of the screen

    drawing

  3. Start writing your code in the Java editor, using VScode built-in code snipplets by pressing CTRL -> SPACE and selecting the requested snipplet

   @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 {
   }

Previous