Currently, I have two services running at different endpoints. For example (this is not my real scenario):
StudentService
CheckHomeWorkService
CheckHomeWorkService
can be used from many services (For example TeacherService, WorkerService
). It has one controller with CheckHomeWork
action. It has some parameters:
HomeWorkNumber (int)
ProvidedSolution (string).
It will return success or failed.
Now, In my StudentService, I have a controller with SubmitHomeWork Action. It needs to check homework using CHeckHomeWorkService and save results to a database. How can I implement this?
I was using Ocelot Api GateWay
but it can 'redirect' to another service and I need to save the result of the response to the database
CodePudding user response:
As suggested in the comments, you can use HttpClient to call the other APIs. However, if you want a more safe and performant solution, you can use also the HttpClientFactory. see this why to use it and see the official docu
CodePudding user response:
You say "I have a controller with SubmitHomeWork Action", so you can pass "CHeckHomeWorkService" in your controller constructor ("Dependency Injection") and call service methods as you like