Notes:
This topic applies to the .NET Core Web API presentation project type only. Refer to Creating a .NET Core Web API RESTful Application for more information.
When you scaffold the .NET Core Web API for AB Suite data sources that contain public methods, you must install the AB Suite Component Enabler software on your development machine.
Scaffolding is the technique used to generate the presentation code that the application can use at run time. The generated code represents a useful starting point for your application that you may want to further modify to refine the application.
Refer to Overview of Scaffolding for more information.
To scaffold one or more data sources in your presentation project, do the following:
Click Build and select Build Solution to build the solution.
In Solution Explorer, right-click the new presentation project name and select Add Unisys ePortal Data Source Reference.
The Add Unisys ePortal Data Source Reference dialog box appears. For more information, refer to Adding Unisys ePortal Data Source Reference.
Select the desired data source project and click OK.
Perform the required actions for each of these following options, and then click OK to start scaffolding.
Note: If scaffolding overwrites any existing files, you are prompted for a confirmation before overwriting.
Dialog Fields
Following are the descriptions for each dialog box options:
ePortal Data Source
Select the name of the data source to scaffold from the list.
Note: If you do not see the data source project that you are looking for, ensure that the data source project is opened in the current solution and a reference has been added. Refer to Using Multiple Data Source Projects for more information.
Controller name
Specify a name for the controller. This name is used as follows:
The name of the controller class is formed by appending "Controller" to the name you specify.
A file named <controllername>Controller.cs is created in the Controllers folder, where <controllername> is the controller name that you specify.
Controller scaffolder
Select the scaffold template to generate the controller code from the list. This list displays the scaffolders present in the CodeTemplates/AddController directory.
Refer to Scaffold Templates and Creating Custom Scaffold Templates for more information.
Scaffold configuration
Following are the descriptions for each option under Scaffold configuration:
Route Prefix
Specify the route prefix to apply to all routes using attribute routing.
This property works in conjunction with the Route property. When specified, the [RoutePrefix(“<routePrefix>”)] attribute is applied to the controller class.
Refer to REST Route Collection Editor for more information on the route rules that the prefix must conform to.
Session required
If the web service requires a session (that is, a stateful application), select this option.
Include All Client Messages
Select this check box to specify that default action methods should be generated for all unorchestrated client messages.
Generate ABSuite/EAE List Actions
Select this check box to specify that individual list action methods should be generated for the Web API. This is based on the information defined in the XML files generated by AB Suite and imported into ePortal Developer.
Note: This option is used only for AB Suite data source projects.
Handling Lists for AB Suite/EAE Connections in the .NET Core Web API Environment
AB Suite/EAE can generate a list of information that is sent to the client in an Ispec response. These list details can then be used in the client application logic.
For an AB Suite data source project, the scaffolder in a .NET Core Web API presentation project will generate the following actions in the controller to assist the processing of lists through the Web API:
Generic operation to retrieve a specified list name
Specific operation based on the list type
Generic List Action Method
For an AB Suite data source project, the scaffolder generates a default list action method called GetList, which allows you to retrieve a list that is already downloaded from the AB Suite application. The generic list action method uses the Get verb to retrieve a list resource with the details specified in the query string as follows:
Property | Description |
---|---|
listName | The name of the list as defined in the AB Suite system. List names can be defined in AB Suite with a period (“.”) and asterisk (“*”) in their name. For example, CUST.SALESREP or *.VENDOR The .NET Core Web API Scaffolder converts the list names to keep the compilation of the generated controller module intact. The ‘.’ character is replaced with an underscore and the ‘*’ character is replaced with the string “STAR_”. For example, CUST_SALESREP and STAR_VENDOR. |
displayColumn | The column number (1 – n) of the column that contains display data. |
hostColumn | The column number (1 – n) of the column that contains data to be exchanged in a transaction with the host application. |
listFormat | This is the format definition for the display item in the list. It is used to concatenate column data of a multicolumn list into a single string for the display item. For example, %2%4%5 listFormat can also specify that
For example, the “%255%4” string creates a datatable with individual columns for the first 4 columns in the list from the host. |
useColumnNamesFromList | This is a boolean value that determines whether the column names in the datatable should be substituted with the values in the first row of the list for each column. This allows you to format a list in AB Suite that contains authorized names for the column headings of the datatable. Note: If this option is set to True, the header row is not used for the list data. |
Specific Typed List Action Method
For an AB Suite data source project, the scaffolder generates individual action methods for each list in the data source project. These lists have a unique type that is defined in the server message.
For example, CUSTOMER_ListType and SALESREP_ListType.
The .NET Core Web API enables you to request the list resource with a route to the specific list. This allows the client application to call the required list, which is returned with a model definition that was specified in the server message.
The following are the default values for the list model:
hostColumn
displayColumn
Notes:
If you want to change the default names of this model to authorized names, update the server message list type definition to replace the hostColumn and DisplayColumn ID with custom values.
The changes to the server message is overwritten on a subsequent import of the Ispec.
By default, generating actions for individual list types is turned off. To generate the individual list action methods, set the GenerateListActions Orchestration property to True. When GenerateListActions Orchestration is set to True, the scaffolder generates an action method for each list.
Note: By default, the GenerateListActions property is set to False.
Using Public Methods for AB Suite Connections in the .NET Core Web API Environment
An AB Suite application enables you to expose public methods to an external client application using the RATL protocol and the Component Enabler API. The ePortal AB Suite Connector uses this capability to execute public method calls to an AB Suite application.
Note: The public method calls are applicable only for AB Suite applications. They are not supported by EAE.
For more information on making a Public Method call from an ePortal Presentation project, refer to Controlling the Runtime Behavior for AB Suite and EAE .
For an ASP.NET Core Web API project, when an AB Suite application exposes one or more public methods, ePortal scaffolds an operation for each public method in the generated controller.
Artifacts Generated in the .NET Core Project
When an AB Suite bundle folder that generates ePortal metadata, contains public method definitions, some additional files are generated in the Component Enabler output directory.
The Component Enabler output directory has an ispecs sub folder, which contains the following two files that defines the composition of the exposed AB Suite public methods:
<name>_PublicMethodList.cs: This is a c# source file.
<name>_PublicMethodList.dll: This is the corresponding assembly.
Where, <name> is the name of the project.
Using the PublicMethodList.dll assembly, the .NET Core Web API scaffolding process finds the public method calls that are available and generates an action for each method in the controller.
The following public method details are generated from an AB Suite application:
Public method name
Type of each parameter in the method signature
Order of each parameter in the method signature
Note: The public method metadata generated from AB Suite does not include the name of each parameter. When the operations are scaffolded, the parameter names are generated as “Param_x” where, “x” is the order of the parameter.
For each public method, an action method is created in the .NET Core Web API controller. The operation accepts a model that defines the parameters of the public method call and their values. This parameter model is passed to the operation using the FromBody directive. To facilitate this approach, the PublicMethodModels.cs file is created in the Models folder of the .NET Core Web API project.
The PublicMethodModels.cs file contains a class definition for each public method and it defines a corresponding data model for the public method and its parameters.
Sample Code
The following example shows a public method called PMTESTSTRING with the configurations defined in an AB Suite application:
Parameter 1 (Result) is a Boolean with direction Out
Parameter 2 (PARAMSTRINGIN) is a String (length 10) with direction In
Parameter 3 (PARAMSTRINGOUT) is a String (length 10) with direction Out
Parameter 4 (PARAMSTRINGINOUT) is a String (length 20) with direction InOut
This public method will have the following class generated in the PublicMethodModels.cs file:
// Model class for PMTESTSTRING public method call. [DataContract] public class PMTESTSTRING { [DataMember] public bool Param_1 { get; set; } [DataMember] public string Param_2 { get; set; } [DataMember] public string Param_3 { get; set; } [DataMember] public string Param_4 { get; set; } }
The corresponding action method in the Web API Controller will have the following signature:
[HttpPost] [Route("PMTESTSTRING")] [ProducesResponseType(200, Type = typeof(PMTESTSTRING))] [SwaggerOperation(OperationId = "CallPMTESTSTRING")] public IActionResult CallPMTESTSTRING([FromBody] PMTESTSTRING ParamData)
For example, if the public method call contains a date parameter, then the generated class for that public method includes a member called “DateFmt” that allows you to specify the date format used to convert a C# DateTime to the required AB Suite date format.
Notes:
The generated classes that support the public method calls, contains both Request and Response parameters. This is because the metadata created from AB Suite does not contain the direction attribute for each parameter.
Unisys recommends to back-up any custom modifications because, if the application is scaffolded again, the changes will be overwritten.