2022 June Release

AppendixPermanent link for this heading

Additional information for specific topics can be found here.

Web ServicesPermanent link for this heading

This chapter provides an overview of how to write your own web services with Fabasoft app.ducx.

Basically, there are two ways to create a new web service:

  • Create a web service as a new WebServiceDefinition instance.
  • Create a web service by extending the WebServiceConfiguration.

Web Service DefinitionPermanent link for this heading

Creating a web service with a new instance of WebServiceDefinition is the recommended way. You just have to implement a use case and then expose it via a WebServiceDefinition.

Example

instance WebServiceDefinition MyWebServices {
  webserviceactions<webserviceoperation, webserviceaction> = {

    {
"MyConcreteWebService", MyWebserviceAction}
  }

}

You can call the web service via the following URL:

https://<host>/<vdir>/wsjson/MYDEMOAPP_111_100_MyWebServices/MyOperation

Web Service ConfigurationPermanent link for this heading

Extending the WebServiceConfiguration is not as simple as creating a WebServiceDefintion but it allows you to control the input and output handling or creation of RESTful web services.

The following example shows a configuration of a web service:

Example

extend instance FSCOWS@1.1001:WebServiceConfiguration {
  FSCOWS@1.1001:friendlyurlconfig<FSCOWS@1.1001:friendlyurlurl,

    FSCOWS@1.1001:friendlyurlaction,

    FSCOWS@1.1001:friendlyurlincont,

    FSCOWS@1.1001:friendlyurloutcont,

    FSCOWS@1.1001:friendlyurlparams<FSCOWS@1.1001:friendlyurlparamnr,      

      FSCOWS@1.1001:friendlyurlparamname>,

    FSCOWS@1.1001:friendlyurlallowedmethods,

    FSCOWS@1.1001:friendlyurlswc> =

  {  

    {

      
"mywebservice",
      MyWebserviceOperation,

      
null,
      
null,
      
null,
      {

        
HTTPMETHOD_GET
      },

      MYDEMOAPP@111.100

    }

  }

}

You can call the web service with the following URL:

https://<host>/<vdir>/mywebservice

RESTful Web ServicesPermanent link for this heading

If you are not familiar with the REST architecture please check out this Wikipedia article: http://de.wikipedia.org/wiki/Representational_State_Transfer

Basically, you can put this architecture into practice by extending the WebServiceConfiguration by adding the typical REST HTTP verbs (we call it friendlyurlallowedmethods):

Example

extend instance FSCOWS@1.1001:WebServiceConfiguration {
  FSCOWS@1.1001:friendlyurlconfig<FSCOWS@1.1001:friendlyurlurl,

    FSCOWS@1.1001:friendlyurlaction,

    FSCOWS@1.1001:friendlyurlincont,

    FSCOWS@1.1001:friendlyurloutcont,

    FSCOWS@1.1001:friendlyurlparams<FSCOWS@1.1001:friendlyurlparamnr,      

      FSCOWS@1.1001:friendlyurlparamname>,

    FSCOWS@1.1001:friendlyurlallowedmethods,

    FSCOWS@1.1001:friendlyurlswc> =

  {  

    {

      
"mywebservice",
      MyWebserviceOperation,

      
null,
      
null,
      
null,
      {

        
HTTPMETHOD_GET,
        HTTPMETHOD_PUT,

        HTTPMETHOD_DELETE,

        HTTPMETHOD_OPTIONS

      },
      MYDEMOAPP@111.100

    }

  }

}

Now you have to create the concrete web service:

Example

public MyWebserviceAction () {
  
variant Object {
    
impl = expression {
      
coort.Trace("incoming method", #TV.TV_FRIENDLYURL_INCOMING_METHOD);      

      if (#TV.TV_FRIENDLYURL_INCOMING_METHOD == “GET”) { /* your code */  }
      
if (#TV.TV_FRIENDLYURL_INCOMING_METHOD == “DELETE”) { /* your code */  }
      
if (#TV.TV_FRIENDLYURL_INCOMING_METHOD == “PUT”) { /* your code */  }
      
if (#TV.TV_FRIENDLYURL_INCOMING_METHOD == “POST”) { /* your code */  }
    }

  }

}

JSONPPermanent link for this heading

If you are not familiar with JSONP, consult: http://en.wikipedia.org/wiki/JSONP. Basically, all web services defined by WebServiceDefinition support JSONP.

You can set the JSONP parameter in GET requests. The parameter contains the name of the callback function that should be executed when the web service has finished.

Example

https://at.cloud.fabasoft.com/folio/wsjson/FSCTEAMROOM_1_1001_TeamRoomWebService/TeamRoomInvitations?jsonp=myCallbackFunction

This returns:

myCallbackFunction({"results":0,"invitations":null})

Note that by using JSONP you are limited to GET requests, since this technique only includes an “external” script and you cannot “include” a script, for example with a POST request. Parameters can therefore not be passed within the request body, but only in the URL.

Create an HTTP RequestPermanent link for this heading

With app.ducx you can perform an HTTP request to gather information, for example from external web services.

Example

usecase DoHttpRequest() {
  
variant Object {
    
impl = expression {
      dictionary resphead;

      content response;

      string url=
"http://www.google.com";
      coouser.FSCOWS@1.1001:SendHttpRequest(
"GET",url,,,&resphead,&response);
    }

  }

}

OpenAPI Permanent link for this heading

Fabasoft app.ducx allows you to import an OpenAPI service definition into your Fabasoft app.ducx project via an import wizard using “File” > “Import”. In the category “Fabasoft app.ducx” you will find an item called “OpenAPI Specification into Fabasoft app.ducx Project”.

On the next page, you have to select an OpenAPI specification in yaml format.

By finishing this dialog, an OpenAPI server definition will be transformed into the necessary types for a client class or a server class and an implementation template to implement the server with Fabasoft app.ducx expression code.

Note: The generated code contains a reference to the imported file so it is recommended to have the imported specification in the resources folder of the project.

Object Classes Without Mandatory TranslationPermanent link for this heading

The following table shows object classes that do not require a multilingual string.

Object Class

Domain-Specific Construct

COOAR@1.1:ActiveReport_Text

ActiveReport_Text

COOAR@1.1:ActiveReport_Web

ActiveReport_Web

COOAR@1.1:ActiveReportingAction

ActiveReportingAction

COOAR@1.1:ContentEvaluationAction

ContentEvaluationAction

COOATTREDIT@1.1:ButtonAction

ButtonAction

COOATTREDIT@1.1:DeskForm

deskform

COOATTREDIT@1.1:DisplayItem

DisplayItem

COOATTREDIT@1.1:FormPage

formpage

COOATTREDIT@1.1:ObjectEditForm

ObjectEditForm

COODESK@1.1:MenuRoot

menuroot

FSCCALDAV@1.1001:VTimezone

VTimezone

FSCOWS@1.1001:SOAPAction

SOAPAction

FSCVAPP@1.1001:Application

Application or automatically generated reference by a menu usecase

COOSYSTEM@1.1:Action

<action reference>

COOSYSTEM@1.1:MethodDefinition

MethodDefinition

COOSYSTEM@1.1:Prototype

Prototype

COOSYSTEM@1.1:UseCase

usecase

COOSYSTEM@1.1:TypeAggregateDef

struct

COOSYSTEM@1.1:TypeEnumDef

enum

COOSYSTEM@1.1:TypeCustomizationPointDef

<customization definition reference>

COOXML@1.1:XMLSchema

XMLSchema

FSCOWS@1.1001:WebServiceDefinition

WebServiceDefinition