you have to expose the service methods as endpoints in the application. To do that, add a rest-services.xml into the root path of the web module which contains:
@mario Thanks you, I was missing the web property.
I have another few more short questions about the subject if I may.
in .net core, the webapi rest service manager understands everything naturally.
let’s say you want to define a service.
you just do, and that’s it. no XML configurations for that.
[Route("api/[controller]")]
[ApiController]
public class TodoController : ControllerBase
{
[HttpGet("{id}")]
public ActionResult<TodoItem> GetById(long id)
{
}
}
//GET /todo/1
I assume java has a library that may act like that (much much less configurations), is it possible in the context of cuba to implement?
Question about the token, once I did login via the rest service, the token life is very short. and I need to refresh it very often. is there a mecanism that the token can live for longer time?
I want to allow customers to register to the system, I have a CustomerEntity and needs to have a relation to UserEntity of type customer with role customer. Do you have a manual how to implement that?
what you showed there is an HTTP endpoint controller in C#. There is an equivalent to that in the Java / Spring world, but it is not a Service. A Service is normally the business logic abstraction, that does not deal with HTTP endpoints and so on. The fact that it is possible in CUBA to expose it as an HTTP endpoint, is more of an edge / ease-of-use case, not so much the default way. This is also why you have to explicitly expose the methods as endpoints in configuration files.
But it would be interesting to see which problem you are trying to solve here. Since there is a generic REST API already available out of the box: REST API - CUBA Platform. Developer’s Manual a lot of use-cases (not all) can be tackled through this probably, at least as a starting point…
@mario, Thank you. I will explore both of them. I think that the cuba api is the spring one with all the configuration that im “complaining about”.
Can you please answer number 3?
I want to allow customers to register to the system, I have a CustomerEntity and needs to have a relation to UserEntity of type customer with role customer. Do you have a manual how to implement that?