日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網營銷解決方案
WCF版本更新應用直接修改方法實現(xiàn)

大多數(shù)開發(fā)人員在使用WCF進行版本更新時,大部分都會通過繼承的方式來實現(xiàn)。那么,還有沒有其他更加簡便的方式呢?下面我們就為大家介紹一種直接修改原有服務和數(shù)據類型的方法來實現(xiàn)WCF版本更新。

創(chuàng)新互聯(lián)建站于2013年開始,是專業(yè)互聯(lián)網技術服務公司,擁有項目成都網站建設、成都做網站網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元臥龍做網站,已為上家服務,為臥龍各地企業(yè)和個人服務,聯(lián)系電話:13518219792

WCF版本更新測試原型:

 
 
 
  1. [DataContract]  
  2. public class Data  
  3. {  
  4. [DataMember]  
  5. public int x;  
  6. }  
  7. [ServiceContract]  
  8. public interface IMyService  
  9. {  
  10. [OperationContract]  
  11. void Test(Data d);  

客戶端代理

 
 
 
  1. //------------------------------------------  
  2. // < auto-generated> 
  3. // 此代碼由工具生成。  
  4. // 運行庫版本:2.0.50727.42  
  5. //  
  6. // 對此文件的更改可能會導致不正確的行為,并且如果  
  7. // 重新生成代碼,這些更改將會丟失。  
  8. // < /auto-generated> 
  9. //-------------------------------------------  
  10. namespace ConsoleApplication1.localhost  
  11. {  
  12. [GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]  
  13. [DataContractAttribute(Namespace = "...")]  
  14. [SerializableAttribute()]  
  15. public partial class Data : object, IExtensibleDataObject  
  16. {  
  17. [OptionalFieldAttribute()]  
  18. private int xField;  
  19. [DataMemberAttribute()]  
  20. public int x  
  21. {  
  22. get  
  23. {  
  24. return this.xField;  
  25. }  
  26. set  
  27. {  
  28. this.xField = value;  
  29. }  
  30. }  
  31. }  
  32. [GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]  
  33. [ServiceContractAttribute(ConfigurationName = 
    "ConsoleApplication1.localhost.IMyService")]  
  34. public interface IMyService  
  35. {  
  36. [OperationContractAttribute(Action = "http://tempuri.org/IMyService/Test", 
    ReplyAction = "...")]  
  37. void Test(Data d);  
  38. }  
  39. [GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]  
  40. public interface IMyServiceChannel : IMyService, IClientChannel  
  41. {  
  42. }  
  43. [DebuggerStepThroughAttribute()]  
  44. [GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]  
  45. public partial class MyServiceClient : ClientBase< IMyService>, 
    IMyService  
  46. {  
  47. public void Test(Data d)  
  48. {  
  49. base.Channel.Test(d);  
  50. }  
  51. }  

我們將對該服務和數(shù)據類型進行升級,添加新的成員和服務方法來實現(xiàn)WCF版本更新。

 
 
 
  1. [DataContract]  
  2. public class Data  
  3. {  
  4. [DataMember]  
  5. public int x;  
  6. [DataMember]  
  7. public int y;  
  8. }  
  9. [ServiceContract]  
  10. public interface IMyService  
  11. {  
  12. [OperationContract]  
  13. void Test(Data d);  
  14. [OperationContract]  
  15. void Test2(int x);  

測試結果表明,客戶端在不更新代理文件的情況下依然正常執(zhí)行??磥碇苯油ㄟ^修改進行版本更新也沒有什么問題。要是我們修改了成員的名稱會怎么樣?也沒問題,不過要使用 Name 屬性了。

 
 
 
  1. [DataContract]  
  2. public class Data  
  3. {  
  4. [DataMember(Name="x")]  
  5. public int x2;  
  6. [DataMember]  
  7. public int y;  
  8. }  
  9. [ServiceContract]  
  10. public interface IMyService  
  11. {  
  12. [OperationContract]  
  13. void Test(Data d);  
  14. [OperationContract]  
  15. void Test2(int x);  

WCF版本更新的操作提示:

1. ***為服務和相關成員特性添加 Namespace / Name 屬性。

2. 還是使用繼承方式進行版本更新要好些,避免因為意味更改造成原有客戶端無法執(zhí)行。


新聞名稱:WCF版本更新應用直接修改方法實現(xiàn)
文章起源:http://www.5511xx.com/article/djieehd.html