简体   繁体   English

在WCF服务应用程序中从单独的dll托管WCF服务

[英]Hosting WCF service from separate dll in WCF service application

I have a WCF service in a service library and I'm trying to host it in a WCF service application. 我在服务库中有一个WCF服务,并且我试图将其托管在WCF服务应用程序中。 I modified the .svc file accordingly 我相应地修改了.svc文件

<%@ ServiceHost Language="C#" Debug="true" Service="Mandrake.Service.OTAwareService" Factory="Mandrake.Service.OTServiceHostFactory"  %>

And I added the stuff that was originally in the service library's app config to the service application's web.config file. 然后,我将服务库的应用程序配置中最初包含的内容添加到服务应用程序的web.config文件中。 I thought it overrides the settings defined in the library's app.config, but it turned out if I remove the app.config file from the library and host the service application on IIS with the web.config containing the necessary endpoint setup (which worked previously) the service doesn't get started and says I have no endpoint defined. 我以为它会覆盖库的app.config中定义的设置,但是事实证明,如果我从库中删除app.config文件,并使用包含必需的端点设置的web.config将服务应用程序托管在IIS上(以前可以使用)服务无法启动,并说我没有定义端点。

My web.config's servicemodel section is as follows: 我的web.config的servicemodel部分如下:

<system.serviceModel>

<serviceHostingEnvironment>
  <serviceActivations>
    <add service="Mandrake.Service.OTAwareService"
         factory="Mandrake.Service.OTServiceHostFactory"
         relativeAddress="OTService.svc"/>
  </serviceActivations>
</serviceHostingEnvironment>

<behaviors>
  <serviceBehaviors>
    <behavior name="StandardBehavior">
      <serviceMetadata />
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="Mandrake.Service.OTAwareService" behaviorConfiguration="StandardBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8062/OTService"/>
      </baseAddresses>
    </host>

    <endpoint address="" binding="netTcpBinding" name="TcpEndpoint" contract="Mandrake.Service.IOTAwareService" />
    <endpoint address="mex" binding="mexTcpBinding" name="MetadataEndpoint" contract="IMetadataExchange" />

  </service>
</services>
</system.serviceModel>

Is there a way I can host this service from the service library in my service application? 有什么方法可以从服务应用程序中的服务库托管此服务?

Most probably you may not have net.tcp binding enabled on website where you are hosting your service application. 最有可能您要在托管服务应用程序的网站上未启用net.tcp绑定。 Check in iis if net.tcp is there in list of bindings. 检查iis绑定列表中是否存在net.tcp。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM