Using Web API Client Libraries
Web API client libraries allow you to work with external APIs using proxy methods native to the FintechOS development environment. Web API client libraries are generated automatically by Innovation Studio from OpenAPI or WSDL specification files supplied by the web service provider. Once generated, you can import the library into any server automation script that requires access to the API.
Some of the advantages of Web API client libraries are:
- less code to write and maintain
- simplified authorization and authentication
- better code consistency and robustness
You can access the API specification files of a FintechOS instance at the following locations:
- OpenAPI: <host_address>/api/openapi/swagger
- WSDL: <host_address>/Services/ApiService.svc
How to create a Web API client library from an OpenAPI or WSDL specification file
When importing WSDL specification files, Innovation Studio uses the Windows Communication Foundation (WCF) dotnet-svcutil tool to generate the Web API client libraries. Make sure that dotnet-svcutil is installed on the deployment server either as a global tool or as a local tool in the bin directory.
You should install the .Net core runtime version that corresponds to the FintechOS instance, even if there are other versions installed on the machine. For more details regarding the installation, go to https://docs.microsoft.com/en-us/dotnet/core/additional-tools/dotnet-svcutil-guide.
Additionally, depending on your .NET Core SDK version, run the following commands:
- In the Main Menu, go to Advanced > Web API Client Libraries.
- In the Web API Client Libraries List page, click the Insert () button at the top right corner of the page.
- Fill in the library's details.
- Name - Enter a name for the Web API client library.
- Description - Optional library description.
- API Type - Select whether the source file uses the OpenAPI or WSDL standard.
- Min Platform Version - Optionally select the oldest API version endpoints you wish to extract from the source file.
- API Definition - Paste the contents of the OpenAPI or WSDL specification file.
- Click the Save and Reload () button at the top right corner of the page. After the library is generated, you can review its definitions in the Typescript Definition tab.
- Click the Save and Close () button at the top right corner of the page.
How to use a Web API client library in server automation scripts
In your automation script, use the importWebApiClient function to import the Web API client library in a JSON object that contains the API specifications. The object exposes methods matching the API's endpoints and has full IntelliSense auto-complete support.
For details, see the Server SDK Reference Guide.
Add certificate support to WebApi client and WCF client
WebAPI client offers a way for consuming external web services by providing a definition for the external service with an OpenAPI or Wsdl file and import it into the platform and provide an object to use. This feature allows a user to work with web services and web sites that require a certificate authentication for example Certsign.
To do so, the user needs a valid certificate.
There is a method for this process setCertificate which accepts workflow client certificate, this is to actually use a certificate. By using a server method that provides the certificate, this method uses the configurations from web.config. In the web.config file, the certificate needs to be configured by providing a storeLocation, storeName, thumbPrint.