Skip to content

4 Extending

Fabio Filardi edited this page Jun 2, 2019 · 6 revisions

Custom Controllers

To extend the API functionality and create new controllers, follow the steps below:

1 - Setup and activate your AIF Inboud port for the service you want to wrap, and copy the WSDL URI.

AIF Inbound port setup

2 - On Visual Studio, add a Service Reference using the WSDL URI from your AIF service.

Service reference

3 - Right-click on Controllers folder, select Add -> Controller, choose "Web API 2 Controller - Empty" and name it as "ExpenseController"

4 - Replace the default code (blank class) by this sample:

Controller code

5 - Rebuild your project, deploy and open the new URL

https://<your-webapp-url:port>/expense/{expense-number}

GET https://localhost:44300/expense/000023

Expense result sample

Caching

To add Cache functionality on controller operations, only two steps are required. First add the reference to the filters namespace on your controller class:

using AxaptaApiApp.Filters;

Then, add the attribute [CacheFilter] on top of you method declaration:

[CacheFilter]
public async Task<IHttpActionResult> Get([FromUri] string expNumber) { ... }

NOTE: Use cache carefully. For more information, check the MemoryCache class documentation.

Clone this wiki locally