Building a Simple Math Service
To begin, create a brand-new WCF Service Library project named MathServiceLibrary, being sure to
select the correct option under the WCF node of the New Project dialog box (see Figure 25-2 if you
need a nudge). Now change the name of the initial IService1.cs file to IBasicMath.cs. Once you
have done so,
delete all of the example code within the MathServiceLibrary namespace and replace
it with the following:
namespace MathServiceLibrary
{
[ServiceContract(Namespace="www.Intertech.com")]
public interface IBasicMath
{
[OperationContract]
int Add(int x, int y);
}
}
Next, change the name of the Service1.cs file to MathService.cs, and (once again) delete all
the example code within the MathServiceLibrary namespace and implement your service contract
as so:
namespace MathServiceLibrary
{
public class MathService : IBasicMath
{
public int Add(int x, int y)
{
Do'stlaringiz bilan baham: |