<分区>
Possible Duplicate:
why you cant overload a method in WCF?
我正在从事一个使用 WCF 服务的项目。我的问题是,在 WCF 服务中,我有一个名为 Display()
的方法,它由我的 client1 使用。
现在我想添加另一个同名但有一个参数的方法,即。 Display(string name)
,让新clinet2使用新方法,旧client1使用旧方法。我怎样才能做到这一点?这是我编写的代码。
namespace ContractVersioningService
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string Display();
[OperationContract]
string GoodNight();
}
}
namespace ContractVersioningService
{
public class Service1 : IService1
{
public string Display()
{
return "Good Morning";
}
public string GoodNight()
{
return "Good Night";
}
}
}
namespace ContractVersioningService
{
[ServiceContract(Namespace = "ContractVersioningService/01", Name = "ServiceVersioning")]
public interface IService2 : IService1
{
[OperationContract]
string Disp(string greet);
}
}
namespace ContractVersioningService
{
public class Service2 : Service1, IService2
{
public string Display(string name)
{
return name;
}
public string Disp(string s)
{
return s;
}
}
}