[英]WCF Service in Separate Assembly
在单独的程序集中创建WCF服务但在同一解决方案中通过Web项目公开其端点的正确方法是什么?
I've done it this way: 我这样做了:
MyServiceLib
MyServiceLib
这样的命名空间中 Add to your web project a file like MyService.svc
with only one statement, the ServiceHost directive: 向您的Web项目添加一个像
MyService.svc
这样的文件,只有一个语句ServiceHost指令:
<%@ 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. 其中
MyServiceLib
是WCF服务和的命名空间的名称MyService
服务实现类的名称。 (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.) (这种简单的设置适用于将服务部署为compliled程序集的情况(例如,在
Bin
目录中)。如果要在第一次请求时使用source和let complile进行部署,则需要向服务主机添加更多属性指令(编程语言,源文件等)
web.config
in the <system.serviceModel>
section. <system.serviceModel>
部分的web.config
中。 我更喜欢在自己的程序集中分离我的契约和实现 ,这有助于在未来的基础上实现基于相同合同的替代实现。
如果您同时控制服务器和客户端,则可以使用此链接中描述的方法: http : //www.dnrtv.com/default.aspx?showNum = 122
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.