Sharing Interfaces Between a WCF Service and Client (marked w/ ServiceContract)

有些话、适合烂在心里 提交于 2019-12-04 11:31:34

Provide access to 'raw' service contracts interfaces to client (assembly or link to .cs file). Then you have two options:

1) Wrap autogenerated proxy calls into your own class method calls (implement interfaces as you want). Service reference updating won't hurt you.

2) Don't use autogenerated proxy. Create your own proxy (implement your interfaces):

var baseAddress = "net.tcp://localhost:4503/MyService"; 
var channelFactory = new DuplexChannelFactory<IMyService>(new InstanceContext(new MyNotificationReceiver()), //MyNotificationReceiver - WCF callback implementation class
    myNetTcpBinding,
    new EndpointAddress(baseAddress));

var proxy = channelFactory.CreateChannel();
proxy.MyMethod();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!