I am working with a mature application which is built in .net Framework 4.5 (upgraded to 4.8 in the test environment). I am a student and there are many things I don't fully understand in the application. I will try my best to explain what I understand so far.
There are two solutions, Solution A and Solution B. Solution A has two projects, one of the project is using IIS Express and is using REST API here, and the other project is integrating WCF services from the solution B. There are proxy classes as well.
Solution B is implementing WCF services in one of its project. In this project, I can see attributes like ServiceContract and OperationContract, but not DataContract.
Now my task is to convert few methods which are using WCF services to RESTful API. I don't know if I should create a new asp.net core project or if I should use the same project where WCF is already implemented and start implementing REST API here. My second problem is how will I handle end-points, and how will I integrate REST API into the Solution A? Should I create an asp.net core webapi project and make Models and Controllers?
Any help is appreciated. =)
Attempt to Add REST API to Existing WCF Project to the Solution B:
I was trying to implement REST APIs alongside the WCF services. However, I am unsure how to test the controller method using Postman. Since Solution A integrates WCF services from Solution B through proxy classes, I'm uncertain how adding RESTful APIs in Solution B affects these integrations. I haven't made any changes to Solution A in response to the new controllers.
Creating a New ASP.NET Core Web API Project:
I also created a new asp.net webapi project aiming to migrating specific WCF service functionalities to RESTful APIs. I created a controller, but WCF project is very complex. There are many dependencies. I am getting this error when I run the project:
System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Integration.Data.Interfaces.IUserDataService Lifetime: Scoped ImplementationType: Integration.Data.Services.UserDataService': Unable to resolve service for type 'DirectoryService.IDirectoryUserService' while attempting to activate 'Integration.Data.Services.UserDataService'.)'
I tried adding a reference of WCF project to my new api project, but the error was not solved. Currently, my web api project has no Model classes.
I can give you an example of adding a Rest API to a WCF project:
1.Install the relevant packages on Nuget
2.Add two classes
3.Add a Global.asax
4.Add API Controller
5.Output: