Open Closed

Could not found remote action for method in New Microservice Project #2899


User avatar
0
AdamMusson created

Could not found remote action for method Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v5.2.0
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Microservice Pro Template
  • Exception message and stack trace:Could not found remote action for method CreateAsync
  • *Steps to reproduce the issue
  1. I created a microservice solution using ABP Suite.
  2. I then used the CLI to add a new microservice to the services folder
  3. FOllwed the steps in the article https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice?msclkid=960a54d5bad011eca8c9b192b6a8ffc5 to get the service running
  4. Created a simple Entity Category with only a Name property and followed the ProductService example.
  5. Added the URL to the CorsOrigins in the Auth Server
  6. Generated the csharp client proxies using the CLI abp generate-proxy -t csharp -u https://localhost:44725 -m CategoryService
  7. I seeded the database with 2 records
  8. When I run the solution the GetListAsync works and returns the items in the database but the CreateAsync and GetAsync(id) both throw the Could not found remote action for method CreateAsync The HttpApi controller code is
[RemoteService(Name = CategoryServiceRemoteServiceConsts.RemoteServiceName)]
    [Area("categoryService")]
    [Route("api/category-service/categories")]
    public class CategoryController : CategoryServiceController, ICategoryAppService
    {
        private readonly ICategoryAppService _categoryAppService;

        public CategoryController(ICategoryAppService categoryAppService)
        {
            _categoryAppService = categoryAppService;
        }
//doesn't work
        [HttpGet]
        [Route("{id}")]
        public virtual Task<CategoryDto> GetAsync(Guid id)
        {
            return _categoryAppService.GetAsync(id);
        }
//works
        [HttpGet]
        public virtual Task<PagedResultDto<CategoryDto>> GetListAsync(GetCategoriesInput input)
        {
            return _categoryAppService.GetListAsync(input);
        }
//doesn't work
        [HttpPost]
        public virtual Task<CategoryDto> CreateAsync(CategoryCreateDto input)
        {
            return _categoryAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public virtual Task<CategoryDto> UpdateAsync(Guid id, CategoryUpdateDto input)
        {
            return _categoryAppService.UpdateAsync(id, input);
        }
        [HttpDelete]
        [Route("{id}")]
        public virtual Task DeleteAsync(Guid id)
        {
            return _categoryAppService.DeleteAsync(id);
        }
    }
}

Where am I going wrong? Is there something simple I am missing. Thanks.


3 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi @AdamMusson

    I'm trying to reproduce this issue and I have some questions about it?

    • Did you create a new service with the name CategoryService?
    • Is your Category entity and appservice in ProductService or your newly created service?
    • Is the URL https://localhost:44725 gateway's URL or the newly created service's url?
  • User Avatar
    0
    AdamMusson created

    Hi enisn, Thanks for looking at this. I created a new service with the name CategoryService using the abp cli command to add it to the services directory of the main solution. The Category entity is in the new CategoryService domain and all the code looks similar to that in the ProductService except that it is dealing with Category and the CategoryDtos. Category is defined as

     public class Category : Entity<Guid>
        {
            public string Name { get; private set; }
    
            protected Category()
            {
    
            }
            public Category(Guid id, string name): base(id)
            {
                SetName(name);
            }
            public void SetName(string name)
            {
                Check.NotNullOrEmpty(name, nameof(name), 100, 3);
                Name = name;
    
            }
    
        }
    

    The Url https://localhost:44725 is the Url for the new CategoryService. The Web Gateway URL is https://localhost:44325 which I think is the standard.

    If there is anything else let me know. But I followed the ProductService as a guide very closely and there is very little difference other than the fact that it is dealing with Category entities.

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Can you verify the t-generate-proxy.json file is updated and has those methods in it?

    By the way, I can't reproduce this issue, can you send me an example project with the issue number (#2899)?

    enis.necipoglu@volosoft.com

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11