在单独的程序集中创建WCF服务但在同一解决方案中通过Web项目公开其端点的正确方法是什么?
I've done it this way:
MyServiceLib
Add to your web project a file like MyService.svc
with only one statement, the ServiceHost directive:
<%@ ServiceHost Service="MyServiceLib.MyService" %>
where MyServiceLib
is the name of the namespace of your WCF service and MyService
the name of your service implementation class. (This simple setup is for the case when you deploy your service as a compliled assembly (in the Bin
directory for instance). If you want to deploy with source and let complile on first request you need to put some more attributes to the service host directive (Programming language, Source file, etc.)
web.config
in the <system.serviceModel>
section. 我更喜欢在自己的程序集中分离我的契约和实现 ,这有助于在未来的基础上实现基于相同合同的替代实现。
如果您同时控制服务器和客户端,则可以使用此链接中描述的方法: http : //www.dnrtv.com/default.aspx?showNum = 122
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.