简体   繁体   English

在不影响客户端的情况下更改WCF项目的名称空间

[英]Change namespace of WCF project without affecting clients

We have created and deployed a WCF service which is being consumed by various third parties. 我们已经创建并部署了WCF服务,该服务已被各种第三方使用。

However we now want to change the namespace of the classes in that particular project. 但是,我们现在要更改该特定项目中类的名称空间。 Is there anyway to do this without the third parties having to make any changes their end? 无论如何,是否需要这样做而无需第三方做出任何改变?

Example: 例:

namespace Test.Service 
{
    [ServiceContract]
    public interface MyService 
    { 
         [OperationContract]
         List<People> GetPeople();
    }

    public class MyService : IMyService 
    {
         public List<People> GetPeople() 
         {
            // Logic here
         }
    }
}

namespace Test.Service.DTO 
{
    [DataContract]
    public class Person { }
}

to

namespace Something.Different
{
    [ServiceContract]
    public interface MyService 
    { 
         [OperationContract]
         List<People> GetPeople();
    }

    public class MyService : IMyService 
    {
         public List<People> GetPeople() 
         {
            // Logic here
         }
    }
}

namespace Something.Different.DTO 
{
    [DataContract]
    public class Person { }
}

It actually appears to be a problem mainly with the namespaces for the DTOs that are generated in the WDSL. 实际上,这似乎主要是与WDSL中生成的DTO的名称空间有关的问题。

They are changing to 他们正在改变

http://schemas.datacontract.org/2004/07/Something.Different.DTO 

from

http://schemas.datacontract.org/2004/07/Test.Service.DTO 

Which appears to be causing the results from the calls (which do not error) to not de-serialize so the List ends up being empty. 这似乎导致调用的结果(不会出错)未反序列化,因此列表最终为空。

There shouldn't be any problem as long that internally to the service you make all the refactorings, provided that : 只要在服务内部进行所有重构,就不会有任何问题,只要:

  • You only share WSDL with third parties 您仅与第三方共享WSDL
  • Said another way : you did not provide third parties with a shared library holding the interfaces and [DataContract] classes 换句话说:您没有为第三方提供包含接口和[DataContract]类的共享库

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM