Step 3: Create an ISimpleCalculator interface, Add ServiceContract and OperationContract attribute to the class and function as shown below. You will know more information about these contracts in later session. These contracts will expose method to outside world for using this service.
IMyCalculatorService.cs
Step 4: MyCalculatorService is the implementation class for IMyCalculatorService interface as shown below.IMyCalculatorService.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; namespace MyCalculatorService { [ServiceContract()] public interface ISimpleCalculator { [OperationContract()] int Add(int num1, int num2); } }
MyCalculatorService.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyCalculatorService { class SimpleCalculator : ISimpleCalculator { public int Add(int num1, int num2) { return num1 + num2; } }
No comments:
Post a Comment