你好聪明的人。
所以,我敢于自己做一个WCF服务。 当我在WCF测试实用程序中运行它时,它应该按原样运行。
但是下一步我遇到了一些麻烦。 在IIS中托管WCF服务。
如上所述,该服务与测试实用程序一起使用。
我的解决方案:
为了在IIS中托管我的服务,我创建了一个名为" HostIISTcp"的文件夹。正如你在解决方案中看到的那样,我将我的dll和我的pdb添加到" bin"夹。 据我所知,IIS无法使用app.config文件运行,所以我创建了一个web.config文件,我只需从类库中的app.config文件中复制/粘贴。
web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MyWCFServices.RealKursusService.KursistService">
<endpoint address="" binding="basicHttpBinding" contract="MyWCFServices.RealKursusService.IKursistService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/MyWCFServices/RealKursusService/KursistService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我相信这个问题存在于web.config文件中,请原谅我是一个新手,但我一直在谷歌搜索疯狂,我真的找不到合适的解决方案。
总结: 我是在正确的轨道上吗? 是否有另一个(更好的)解决方案在IIS中托管wcf服务? 如果你能指出web.config文件中是否缺少任何内容,那就太棒了。
我使用visual studio 2012,IIS 8 .net framework 4.5并坐在皮椅上。
答案 0 :(得分:2)
所以我想通了。
顺便说一句,对于vauge问题,我很担心为什么我的wcf服务不会被托管。
我通过以下步骤完成了web.config的工作:
在我新创建的网站中编辑service.svc文件,指向我现有的服务
<%@ ServiceHost Language="C#" Debug="true" Service="MyWCFServices.RealKursusService.KursistService" %>
在我的新网站上删除了web.config中的整个配置。
然后在我的默认网站iis
下的新应用程序中托管svc文件希望这可以帮助某人