hi everyone. I have microservises template. and I am trying to implement commutication between servises vie Integration Services. Do you have same sample how to implement it? In documentation (https://abp.io/docs/latest/solution-templates/microservice/http-api-calls) i can see that on client side we have to use HttpClient. Does it mean we have to use this one (https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-8.0) or something from ABP?
Thank you in advance.
29 Answer(s)
-
0
You can also use the Static or Dynamic C# clients to call the HTTP APIs of other microservices. However, the Integration Services is the recommended way to communicate between microservices because it allows you to hide your endpoints from the outside world and manage your services more easily.
Hi,
I recommend you use the static csharp proxy.
https://abp.io/docs/latest/solution-templates/microservice/http-api-calls https://abp.io/docs/latest/framework/api-development/static-csharp-clients
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
And am I right that in current microservice template we have to create projects manualy (for example Domain, Domain.Shared and so on)? Or maybe ABP has some command vie CLI?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
HI,
we have to create projects manualy (for example Domain, Domain.Shared and so on)
you don't need to do this.
you can configure csharp proxy in the
Webproject[DependsOn( ...... typeof(XXXServiceContractsModule), //Service Contracts module typeof(AbpVirtualFileSystemModule) //virtual file system ..... )] public class XXXWebModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { // Prepare for static client proxy generation context.Services.AddStaticHttpClientProxies( typeof(XXXServiceContractsModule).Assembly, XXXServiceRemoteServiceConsts.RemoteServiceName // add XXXServiceRemoteServiceConsts class to Contracts project ); // Include the generated app-generate-proxy.json in the virtual file system Configure<AbpVirtualFileSystemOptions>(options => { options.FileSets.AddEmbedded<XXXWebModule>(); }); } }Add
generate-proxy.jsonconfig to csproj file<ItemGroup> <EmbeddedResource Include="**\*generate-proxy.json" /> <Content Remove="**\*generate-proxy.json" /> </ItemGroup>Then you can use abp command to generate proxy
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
And I want to split it for a sevrel layers
if you want , you can add them manually.
But the current layering is simpler
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
HI,
we have to create projects manualy (for example Domain, Domain.Shared and so on)
you don't need to do this.
you can configure csharp proxy in the
Webproject[DependsOn( ...... typeof(XXXServiceContractsModule), //Service Contracts module typeof(AbpVirtualFileSystemModule) //virtual file system ..... )] public class XXXWebModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { // Prepare for static client proxy generation context.Services.AddStaticHttpClientProxies( typeof(XXXServiceContractsModule).Assembly, XXXServiceRemoteServiceConsts.RemoteServiceName // add XXXServiceRemoteServiceConsts class to Contracts project ); // Include the generated app-generate-proxy.json in the virtual file system Configure<AbpVirtualFileSystemOptions>(options => { options.FileSets.AddEmbedded<XXXWebModule>(); }); } }Add
generate-proxy.jsonconfig to csproj file<ItemGroup> <EmbeddedResource Include="**\*generate-proxy.json" /> <Content Remove="**\*generate-proxy.json" /> </ItemGroup>Then you can use abp command to generate proxy
I did it in service B and then I ran Service A and tryed to use this command (abp generate-proxy -t csharp -u http://localhost:44331/) in serice B but I get this error System.IO.DirectoryNotFoundException: Could not find a part of the path 'path\Service B\ClientProxies\app-generate-proxy.json'.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
-
0
Hi,
The web project should reference to the
Service.Contractsproject. so, don't need to generate DtosMarkdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
OH, i see, in this way, I recommend you to create a new project named
HttpApi.Client.and configure static proxy in the
HttpApi.ClientprojectMarkdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
should put it in the service solution
MyServiceMyService.HttpApi.ClientMyService.ContractsMarkdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I see it but in which solution?? I have 2 solutions: auth service (client) and Identity (server). In which one I have to add HttpApi.Client
Auth Solution (has just 1 project):
- Service (here I added AbpHttpClient and EmbeddedResource)
Identoty Solution (has 2 projects):
- Service
- Contracts
So as far as I understood I have to add HttpApi.Client project into Auth Solution. Am I right?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Create
HttpApi.Clientproject for each service.[DependsOn( typeof(AbpHttpClientModule), //used to create client proxies typeof(AbpVirtualFileSystemModule) //virtual file system )] public class XXXServiceHttpClientModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { // Prepare for static client proxy generation context.Services.AddStaticHttpClientProxies( typeof(XXXServiceHttpClientModule).Assembly, XXXServiceRemoteServiceConsts.RemoteServiceName ); // Include the generated app-generate-proxy.json in the virtual file system Configure<AbpVirtualFileSystemOptions>(options => { options.FileSets.AddEmbedded<XXXServiceHttpClientModule>(); }); } }then generate proxy file(Dtos, services etc...)
For example:
abp generate-proxy -t csharp -u xxx -m identity (XXXServiceRemoteServiceConsts.RemoteServiceName's value)Other services can then reference this project for API calls
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Create
HttpApi.Clientproject for each service.[DependsOn( typeof(AbpHttpClientModule), //used to create client proxies typeof(AbpVirtualFileSystemModule) //virtual file system )] public class XXXServiceHttpClientModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { // Prepare for static client proxy generation context.Services.AddStaticHttpClientProxies( typeof(XXXServiceHttpClientModule).Assembly, XXXServiceRemoteServiceConsts.RemoteServiceName ); // Include the generated app-generate-proxy.json in the virtual file system Configure<AbpVirtualFileSystemOptions>(options => { options.FileSets.AddEmbedded<XXXServiceHttpClientModule>(); }); } }then generate proxy file(Dtos, services etc...)
For example:
abp generate-proxy -t csharp -u xxx -m identity (XXXServiceRemoteServiceConsts.RemoteServiceName's value)Other services can then reference this project for API calls
it does not help. I have the same result
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
it does not help. I have the same result
what result?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
can you share the generate-proxy command output log?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
The CLI expects the DTOs namespace to start with or be consistent with the application service's namespace.
you can check your dto and service namespace
For example:
namespace MyService.Services .... namespace MyService.Services.DtosMarkdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Does it mean that I have to have DTOs models not in Contracts layer?
no, just the namespace.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)






