如何基于应用项目构建WebAPI远程服务?
How to build Web API remote services based on application project?
我对 ASP.NET 样板还很陌生。
ASP.NET 核心文档中提到:
ASP.NET Boilerplate provides the infrastructure to create application services. If you want to expose your application services to remote clients as controllers (as previously done using dynamic web api), you can easily do that with a simple configuration in the PreInitialize method of your module.
能否请您清楚说明如何将我的应用程序项目中的方法暴露给远程客户端的过程?
例如在Acme.SimpleTaskApp中,有一种列出任务的方法:
public async Task<ListResultDto<TaskListDto>> GetAll(GetAllTasksInput input)
{
var tasks = await _taskRepository
.GetAll()
.Include(t => t.AssignedPerson)
.WhereIf(input.State.HasValue, t => t.State == input.State.Value)
.OrderByDescending(t => t.CreationTime)
.ToListAsync();
return new ListResultDto<TaskListDto>(
ObjectMapper.Map<List<TaskListDto>>(tasks)
);
}
如何公开 GetAll
方法?该方法的获取地址是什么?
api/GetAll
?
非常感谢。
来自 Application Services as Controllers for ASP.NET Core 的文档:
Configuration.Modules.AbpAspNetCore()
.CreateControllersForAppServices(
typeof(AbpProjectNameApplicationModule).Assembly,
moduleName: "app",
useConventionalHttpVerbs: true
);
When an application service is converted to an MVC Controller, its default route will look like: /api/services/<module-name>/<service-name>/<method-name>
.
For example, if ProductAppService defines a Create method, its URL will be /api/services/app/product/create
(assuming that the module name is 'app').
我对 ASP.NET 样板还很陌生。
ASP.NET 核心文档中提到:
ASP.NET Boilerplate provides the infrastructure to create application services. If you want to expose your application services to remote clients as controllers (as previously done using dynamic web api), you can easily do that with a simple configuration in the PreInitialize method of your module.
能否请您清楚说明如何将我的应用程序项目中的方法暴露给远程客户端的过程?
例如在Acme.SimpleTaskApp中,有一种列出任务的方法:
public async Task<ListResultDto<TaskListDto>> GetAll(GetAllTasksInput input)
{
var tasks = await _taskRepository
.GetAll()
.Include(t => t.AssignedPerson)
.WhereIf(input.State.HasValue, t => t.State == input.State.Value)
.OrderByDescending(t => t.CreationTime)
.ToListAsync();
return new ListResultDto<TaskListDto>(
ObjectMapper.Map<List<TaskListDto>>(tasks)
);
}
如何公开 GetAll
方法?该方法的获取地址是什么?
api/GetAll
?
非常感谢。
来自 Application Services as Controllers for ASP.NET Core 的文档:
Configuration.Modules.AbpAspNetCore()
.CreateControllersForAppServices(
typeof(AbpProjectNameApplicationModule).Assembly,
moduleName: "app",
useConventionalHttpVerbs: true
);
When an application service is converted to an MVC Controller, its default route will look like:
/api/services/<module-name>/<service-name>/<method-name>
.For example, if ProductAppService defines a Create method, its URL will be
/api/services/app/product/create
(assuming that the module name is 'app').