Integrating external web services
APS v23 can consume external web services (REST or SOAP) to validate data, synchronize repositories, or trigger actions in third-party systems.
Consumption from an Agent or Script
The most flexible way to call an external service is to use C# code within a scheduled agent or validation script.
Calling a REST API (JSON)
Since .NET Framework 4.8, you can use System.Net.Http.HttpClient.
using System.Net.Http;
using System.Threading.Tasks;
public async Task<string> AppelerApiExterne(string uId)
{
using (var client = new HttpClient())
{
var response = await client.GetAsync("https://api.tierce.com/data/" + uId);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadAsStringAsync();
}
}
return null;
}
Calling a SOAP service
For SOAP services, you can generate a Proxy client via Visual Studio and integrate it into your extension DLL, or use WebRequest classes for more basic calls.
Integration via "Web Requests"
APS also allows you to configure Web Requests directly in Process Studio to:
- Populate dropdown lists: Dynamically load options from an external service.
- Auto-completion: Provide suggestions from an API.
- Data verification: Call a service during field input to validate its format or existence.
Security and Authentication
When calling external services, ensure you properly manage secrets (API keys, OAuth2 tokens).
- Encrypted components: Use APS encryption utilities (
Avanteam.Kernel.Cryptography) to store service passwords in the database. - Timeouts: Always configure short timeouts to avoid blocking web application threads if the third-party service is slow.
SSL Certificates
If you call HTTPS services with self-signed or internal certificates, ensure that the certificates are installed in the certificate store of the server hosting APS.