Editing Web Service Code

The code in an automatically generated Web Service function provides basic Select and Fetch templates for data retrieval. However, there is frequently a need to enhance a function’s code in order to perform a specific functionality.

How Do I Edit a Function's Code In a Web Service?

It is recommended to edit the code in a Web Service function using the IntelliJ Java Editor which offers a number of advantages like:

  • Smart code completion.

  • Inspection and quick fixes.

  • Functions.

  • Navigation and Search options.

Note that IntelliJ is not part of the Fabric Studio Installation Package and must be installed. Once installed, it is integrated into the Fabric Studio and can be invoked by right clicking the Web Service working area and selecting it or by pressing CTRL+I on your keyboard.

A Web Service can also be edited directly in its main working area.

What Should be Edited?

The following items should be edited after they are automatically generated:

Item

Description

Fetch Data Statement

LUDB Fetch Statement. Replace this with the Web Service Input parameter defined as the Fabric LUI identifier. For example, in the wsCustomerInfo Web Service:

  • Input parameter = “ID” 
  • Db.Rows rows = ludb("Customer", ).fetch(sql, , , ...);
  • Db.Rows rows = ludb("Customer", ID).fetch(sql, , , ...); LUDB or DB Interface Fetch Statements

Either populate the SQL query parameters in their placeholders (, ,…) or delete them if they are not required.

These steps are mandatory for a clean Web Service code compilation. For example:

  • Db.Rows rows = ludb("CUSTOMER", ID).fetch(sql, “XX”, 123);
  • Db.Rows rows = ludb("CUSTOMER", ID).fetch(sql);

SQL Statement Enhancement Options

  • Add a WHERE clause.  
  • JOIN additional tables to the query.
  • Add advanced features to the SELECT statement.

For example, assigning identifiers to tables and specifying which table columns to retrieve.

Java Code Enhancement

Web Service code can also apply transformation rules via the functions, translations or Globals defined in the project.

Note that any Fabric server runtime command can be used within the Web Service using the Execute function.

For example, the Get command on the Customer LUT for a specific instance:

Fabric().execute(“ get Customer.?”,ID);

Custom Payload Handling

When required, handle the service request body manually.
To do so, change the Web Service Properties Custom Payroll value to True and change the code to handle the request body using WebServiceUserCode.request().getInputStream().
Note that custom payload supports POST and PUT request methods.

Previous

Editing Web Service Code

The code in an automatically generated Web Service function provides basic Select and Fetch templates for data retrieval. However, there is frequently a need to enhance a function’s code in order to perform a specific functionality.

How Do I Edit a Function's Code In a Web Service?

It is recommended to edit the code in a Web Service function using the IntelliJ Java Editor which offers a number of advantages like:

  • Smart code completion.

  • Inspection and quick fixes.

  • Functions.

  • Navigation and Search options.

Note that IntelliJ is not part of the Fabric Studio Installation Package and must be installed. Once installed, it is integrated into the Fabric Studio and can be invoked by right clicking the Web Service working area and selecting it or by pressing CTRL+I on your keyboard.

A Web Service can also be edited directly in its main working area.

What Should be Edited?

The following items should be edited after they are automatically generated:

Item

Description

Fetch Data Statement

LUDB Fetch Statement. Replace this with the Web Service Input parameter defined as the Fabric LUI identifier. For example, in the wsCustomerInfo Web Service:

  • Input parameter = “ID” 
  • Db.Rows rows = ludb("Customer", ).fetch(sql, , , ...);
  • Db.Rows rows = ludb("Customer", ID).fetch(sql, , , ...); LUDB or DB Interface Fetch Statements

Either populate the SQL query parameters in their placeholders (, ,…) or delete them if they are not required.

These steps are mandatory for a clean Web Service code compilation. For example:

  • Db.Rows rows = ludb("CUSTOMER", ID).fetch(sql, “XX”, 123);
  • Db.Rows rows = ludb("CUSTOMER", ID).fetch(sql);

SQL Statement Enhancement Options

  • Add a WHERE clause.  
  • JOIN additional tables to the query.
  • Add advanced features to the SELECT statement.

For example, assigning identifiers to tables and specifying which table columns to retrieve.

Java Code Enhancement

Web Service code can also apply transformation rules via the functions, translations or Globals defined in the project.

Note that any Fabric server runtime command can be used within the Web Service using the Execute function.

For example, the Get command on the Customer LUT for a specific instance:

Fabric().execute(“ get Customer.?”,ID);

Custom Payload Handling

When required, handle the service request body manually.
To do so, change the Web Service Properties Custom Payroll value to True and change the code to handle the request body using WebServiceUserCode.request().getInputStream().
Note that custom payload supports POST and PUT request methods.

Previous