首页 > Web开发 > 详细

在.NET 4中用IIS部署WCF就这么简单

时间:2014-09-09 11:07:18      阅读:303      评论:0      收藏:0      [点我收藏+]

在.NET 3.5中,我们需要这样做:

1. 添加一个HelloService.svc文件,添加ServiceHost标记,在Service中添加WCF服务实现的名称,比如:

<%@ ServiceHost Language="C#" Debug="false" Service="CNBlogs.Service.Impl.HelloService"%>

2. 在web.config/system.serviceModel/bindings/basicHttpBinding中添加一个binding。

3. 在web.config/system.serviceModel/behaviors/serviceBehaviors中添加一个behavior。

4. 在web.config/system.serviceModel/services中添加一个service,并且:

  a) 设置behaviorConfiguration属性。

  b) 设置name属性。

5. 在service下添加一个endpoint,并且:

  a) 设置binding属性。

  b) 设置name属性。

  c) 设置contract属性。

在.NET 4中,我们只要这样做:

在web.config/system.serviceModel/serviceHostingEnvironment/serviceActivations中增加下面两个属性即可:

<add relativeAddress="HelloService.svc" service="CNBlogs.Service.Impl.HelloService"/>

这样配置后,就可以正常调用WCF服务。

如果需要通过SvcUtil.exe生成客户端代理,只需在serviceBehaviors中添加:

<behavior>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
 
转载出处:http://www.cnblogs.com/dudu/archive/2011/01/18/1938490.html

在.NET 4中用IIS部署WCF就这么简单

原文:http://www.cnblogs.com/TddCoding/p/3961473.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!