我的项目中有两个WCF服务。 服务正在共享一种类型,但每种服务都会生成自己的类型。 是否可以为两种服务生成一个类?对于服务器端两个WCF服务之间的共享类型
示例代码:
[DataContract]
class MyClass { /*some properties*/ }
[ServiceContract]
public interface IService1
{
[OperationContract]
MyClass GetSomeValue();
}
public class Service1 : IService1
{
public MyClass GetSomeValue() { /*some logic*/ }
}
[ServiceContract]
public interface IService2
{
[OperationContract]
MyClass GetSomeOtherValue();
}
public class Service2 : IService2
{
public MyClass GetSomeOtherValue() { /*some logic*/ }
}
在客户端两个 “MyClass的” 正在生成每个服务:
namespace Services.Service1Reference {
[System.SerializableAttribute()]
public partial class RSTRole : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
{
}
和
namespace Services.Service2Reference {
[System.SerializableAttribute()]
public partial class RSTRole : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
{
}
只是为了确认 - 你是消费来自单个客户端的两种不同服务。这些服务本身有一个通用程序集,您希望在所有3个系统中共享这些服务? – StuartLC
是的,你是对的 –
你怎么生成你的代理类?视觉工作室还是svcutil? – KornMuffin