WCF 中的通道工厂
大家好,我是 WCF 新手,我想知道我是否使用通道工厂,以及如果我对服务合同进行任何更改,这些更改是否会在客户端系统中自动更新???如果更改自动更新如何? ??
Hi all i am new to WCF i wanted to know if i use channel factory and if i make any changes in service contract whether the changes will be updated automatically in the client system or not???If the changes are updated automatically how????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,通道工厂不会自动更新 - 您必须更新服务引用(如果您使用 Visual Studio 的添加服务引用添加它),或者需要从 WSDL/XSD 或服务 URL 重新创建客户端代理。
更新:当然,如果您在服务和客户端之间的程序集中共享服务和数据合同,那么您当然可以在获得新的合同后立即更新客户端服务契约 DLL 到位...
如果要启用服务和数据契约的共享,请使用以下设置:
在您的契约程序集中,拥有所有服务契约(接口)和数据契约(数据类型)
在您的服务实现中,引用< code>Contracts 程序集并在服务实现中实现服务约定
您的客户端代理,还引用共享的
Contracts
程序集,并使用ChannelFactory
为服务合约接口T
创建通道工厂>.通过此设置,每当您对共享合约程序集进行更改时,服务实现和客户端代理都将“获取”这些更改,例如,它们始终是最新的并使用相同的服务和数据合约
No, the channel factory is not updated automatically - you have to update your service reference (if you added it using Visual Studio's Add Service Reference) or you need to re-create the client side proxy from the WSDL/XSD or service URL.
UPDATE: of course, if you're sharing the service and data contracts in an assembly between both the service and the client, then of course you have the client up to date as soon as you have the new service contract DLL in place...
If you want to enable this sharing of service and data contracts, use the following setup:
in your Contracts assembly, have all the service contracts (interfaces) and data contracts (data types)
in your implementation of the service, reference that
Contracts
assembly and implement the service contract(s)in your client-side proxy, also reference that shared
Contracts
assembly, and useChannelFactory<T>
to create a channel factory for the service contract interfaceT
.With this setup, whenever you make a change to the shared contract assembly, both service implementation and client side proxy will "get" those changes, e.g. they're always up to date and using the same service and data contracts