WCF - 处理版本控制 [英] WCF - handle versioning

查看:12
本文介绍了WCF - 处理版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我需要退出此服务合同:

If I need to go from this service contract:

[ServiceContract(Namespace="http://api.x.com/Svc1")]
public interface IService1
{
   [OperationContract(Name = "AddCustomer")]
   bool AddCustomer(DTOCustomer1 customer);
}

对此:

[ServiceContract(Namespace="http://api.x.com/Svc1")]
public interface IService1
{
   [OperationContract(Name = "AddCustomer")]
   bool AddCustomer(DTOCustomer2 customer);
}

并根据这篇好文章:Versioning WCF 我知道当数据合同发生变化时,需要在新的命名空间中定义一个新的 vs of 数据合同,然后在新的命名空间中定义一个新的 vs of 服务合同,之后一个新的端点应该添加.

and according to this good article: Versioning WCF I understand that when data contract is changed there is a need of defining a new vs of data contract in new namespace followed by defining a new vs of service contract in new namespace, after which a new endpoint should be added.

我究竟应该如何完成这项工作.有没有任何地方的例子?你能根据我上面显示的服务合同写点什么吗?

How exactly am I suppose to have this done. Is there an example anywhere? Could you write something based on my service contract shown above?

提前谢谢你!

推荐答案

根据链接的文章,您应该执行以下操作:

According to the linked article you should do something like:

[ServiceContract(Namespace="http://api.x.com/Svc1")]
public interface IServiceNew : IService1
{
   [OperationContract(Name = "AddCustomerNew")]
   bool AddCustomer(DTOCustomer2 customer);
}

然后在你的服务中实现它:

Then implement it in your service:

public class MyCurrentServiceImplementation : IServiceNew 
{...}

您将需要重新部署您的服务,但现有客户端应该能够继续调用 AddCustomer 操作,而新客户端可以调用 AddCustomerNew 操作.

You will need to redeploy your service but existing clients should be able to continue to call the AddCustomer operation, and new clients can call the AddCustomerNew operation.

这篇关于WCF - 处理版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆