该例子的过程是:服务逻辑人有了本事,服务通信人和他建立联系。客户指定服务逻辑人,指派客户通信人与服务通信人接触,使用服务逻辑人的本事。
先教服务逻辑人本事。注意先新建类库,再在类库中新建类。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;//在类库中添加引用System.ServiceModel
namespace HelloIndigo//服务逻辑人
{
[ServiceContract(Namespace = "http://www.thatindigogirl.com/samples/2006/06")]//服务逻辑人指定,该本事,能被客户调用(术语:服务契约)
public interface IHeloIndigoService
{
[OperationContract]//服务逻辑人指定,该本事的具体行为,能被客户调用(术语:操作契约)
string HelloIndigo();
}
public class HelloIndigoService:IHeloIndigoService//逻辑人的本事
{
public string HelloIndigo()//该本事的具体行为
{
return "Hello Indigo";
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;//在类库中添加引用System.ServiceModel
namespace HelloIndigo//服务逻辑人
{
[ServiceContract(Namespace = "http://www.thatindigogirl.com/samples/2006/06")]//服务逻辑人指定,该本事,能被客户调用(术语:服务契约)
public interface IHeloIndigoService
{
[OperationContract]//服务逻辑人指定,该本事的具体行为,能被客户调用(术语:操作契约)
string HelloIndigo();
}
public class HelloIndigoService:IHeloIndigoService//逻辑人的本事
{
public string HelloIndigo()//该本事的具体行为
{
return "Hello Indigo";
}
}
}