diff --git a/docs/en/framework/api-development/dynamic-csharp-clients.md b/docs/en/framework/api-development/dynamic-csharp-clients.md index def0b76360..a5dc2ec1cf 100644 --- a/docs/en/framework/api-development/dynamic-csharp-clients.md +++ b/docs/en/framework/api-development/dynamic-csharp-clients.md @@ -163,6 +163,30 @@ context.Services.AddHttpClientProxies( `remoteServiceConfigurationName` parameter matches the service endpoint configured via `AbpRemoteServiceOptions`. If the `BookStore` endpoint is not defined then it fallbacks to the `Default` endpoint. +#### Remote Service Configuration Provider + +You may need to get the remote service configuration for a specific remote service in some cases. For this, you can use the `IRemoteServiceConfigurationProvider` interface. + +**Example: Get the remote service configuration for the "BookStore" remote service** + +````csharp +public class MyService : ITransientDependency +{ + private readonly IRemoteServiceConfigurationProvider _remoteServiceConfigurationProvider; + + public MyService(IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) + { + _remoteServiceConfigurationProvider = remoteServiceConfigurationProvider; + } + + public async Task GetRemoteServiceConfiguration() + { + var configuration = await _remoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("BookStore"); + Console.WriteLine(configuration.BaseUrl); + } +} +```` + ### As Default Services When you create a service proxy for `IBookAppService`, you can directly inject the `IBookAppService` to use the proxy client (as shown in the usage section). You can pass `asDefaultServices: false` to the `AddHttpClientProxies` method to disable this feature. @@ -204,6 +228,8 @@ public override void PreConfigureServices(ServiceConfigurationContext context) This example uses the [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly) package. You also need to import the `Polly` namespace (`using Polly;`) to be able to use the `WaitAndRetryAsync` method. + + ## See Also * [Static C# Client Proxies](./static-csharp-clients.md) diff --git a/docs/en/framework/api-development/static-csharp-clients.md b/docs/en/framework/api-development/static-csharp-clients.md index 696507bd09..c8eaea4231 100644 --- a/docs/en/framework/api-development/static-csharp-clients.md +++ b/docs/en/framework/api-development/static-csharp-clients.md @@ -244,6 +244,30 @@ context.Services.AddStaticHttpClientProxies( `remoteServiceConfigurationName` parameter matches the service endpoint configured via `AbpRemoteServiceOptions`. If the `BookStore` endpoint is not defined then it fallbacks to the `Default` endpoint. +#### Remote Service Configuration Provider + +You may need to get the remote service configuration for a specific remote service in some cases. For this, you can use the `IRemoteServiceConfigurationProvider` interface. + +**Example: Get the remote service configuration for the "BookStore" remote service** + +````csharp +public class MyService : ITransientDependency +{ + private readonly IRemoteServiceConfigurationProvider _remoteServiceConfigurationProvider; + + public MyService(IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) + { + _remoteServiceConfigurationProvider = remoteServiceConfigurationProvider; + } + + public async Task GetRemoteServiceConfiguration() + { + var configuration = await _remoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("BookStore"); + Console.WriteLine(configuration.BaseUrl); + } +} +```` + ### Retry/Failure Logic & Polly Integration If you want to add retry logic for the failing remote HTTP calls for the client proxies, you can configure the `AbpHttpClientBuilderOptions` in the `PreConfigureServices` method of your module class.