WCF Tutorial, Part 4: Service Implementation
-
Create a WCF Service Library and name it RoomReservationService.
-
Add references to
-
RoomReservationContracts
-
RoomReservationData
-
-
Remove the Data Contract class and modify the RoomReservationService.cs as bellow:
using System; using System.ServiceModel; using RoomReservationContracts; using RoomReservationData; namespace RoomReservationservice { [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class RoomReservationService : IRoomService { public bool ReserveRoom(RoomReservation roomReservation) { var data = new RoomReservationData.RoomReservationData(); data.ReserveRoom(roomReservation); return true; } public RoomReservation[] GetRoomReservations(DateTime fromTime, DateTime toTime) { var data = new RoomReservationData.RoomReservationData(); return data.GetReservations(fromTime, toTime); } } }
The service class RoomReservationService implements the interface IRoomService. The service is implemented just by invoking the appropriate methods of the RoomReservationData class.
Following figure shows the assemblies we have created yet and their dependencies.