Project - DwbServices
External Web Services - Integrating Third-Party Data Sources (upcoming version)
The DWBServices project is designed to interact with a variety of taxonomic and geographic web services. It provides a unified interface for querying, retrieving, and processing data from external APIs. The framework abstracts the complexities of individual web services, enabling easy integration and consistent interaction across the DWB modules.
The architecture of the project is designed to support a modular and extensible system for interacting with taxonomic and geographic web services. It leverages dependency injection for service management, configuration-based customization, and abstract base classes to define common behaviors for services. At the moment the system is divided into two main domains: Taxonomic Services and Geo Services, each with their own abstractions (TaxonomicWebservice, GeoService) and entities (TaxonomicEntity, GeoEntity). The class DwbServiceProviderAccessor acts as a central access point for retrieving specific service implementations based on the service type. The architecture ensures scalability, maintainability, and separation of concerns, making it easy to integrate new services.
Adding a new webservice to a DWB Client
To incorporate a new web service into the DiversityCollection or similar projects, follow these steps:
-
Add new folder under TaxonomicServices or GeoServices.
-
Create Entity Classes: Define entity classes inheriting from TaxonomicEntity or GeoEntity to represent the service’s data structure.
-
Implement Search and Result Models: Create search criteria and result classes inheriting from TaxonomicSearchCriteria/GeoSearchCriteria and TaxonomicSearchResult/GeoSearchResult.
-
Implement the Service: Create a new service class inheriting from TaxonomicWebservice or GeoService. Implement required methods like DwbApiQueryUrlString, GetDwbApiSearchModel, and GetDwbApiDetailModel.
-
Add the Service to Enums and Dictionaries: Add the new service to DwbServiceEnums.DwbService. If the service is a taxonomic service, also add it to the TaxonomicServiceInfoDictionary with its relevant configuration details (e.g., name, URL, dataset key).
-
Register the Service in Program.cs: Add the service to the ConfigureServices method:
services.AddHttpClient<NewWebservice>();
-
For the DC Client: Update FormRemoteQuery.InitWebserviceControl(): Add the new service to the initialization logic of the web service control in the FormRemoteQuery class.
-
For the DC Client: Update FormSpreadsheet.FixedSourceSetConnection: Ensure the new service is included in the logic for fixed source set connections in the FormSpreadsheet class.
-
Handle Authentication (if required): If the service requires authentication via a bearer token, override the CallWebServiceAsync methods from DwbWebservice and implement token-based authentication within these methods. For an example, refer to the MycobankWebservice implementation.
-
Update Configuration: Add the new service’s base address and other settings to the configuration file.
-
Test the Integration: Validate the service’s functionality by testing its API calls and data mappings.