命名管道绑定在 Windows 服务中工作,但 BasicHttp 绑定失败
Named Pipes Binding Working in Windows Service, but BasicHttp Binding Failing
我正在尝试使用 http 和命名管道端点构建 windows 服务托管的 WCF 服务。当我将它配置为使用命名管道时,它工作正常,但是当我尝试将它配置为使用 http 绑定时,它会全部编译和安装,但是当我尝试启动该服务时,它立即停止,我不能在事件查看器中找到一条错误消息。
这是我的 app.config 文件。注释里的配置有效,没有注释的配置无效
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config
file must be added to the host's app.config file.
System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="NogginWcf.NogginWcfSvc">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="" name="BasicHttp" bindingName="BasicHttp"
contract="NogginWcf.INogginWcfSvc" />
<endpoint address="mex"
binding="mexHttpBinding" bindingConfiguration="" name="HttpMex"
bindingName="HttpMex" contract="IMetadataExchange" />
<!--<endpoint address="" binding="netNamedPipeBinding"
bindingConfiguration="" name="NamedPipes" bindingName="NamedPipes"
contract="NogginWcf.INogginWcfSvc" />
<endpoint address="mex"
binding="mexNamedPipeBinding" bindingConfiguration="" name="NamedPipesMex"
bindingName="NamedPipesMex" contract="IMetadataExchange" />-->
<host>
<baseAddresses>
<!--<add baseAddress="net.pipe://localhost/NogginPipesService" />-->
<add baseAddress="http://localhost:8000/NogginHttpService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
This MSDN tutorial 演示了使用 windows 服务托管 http 端点,我认为我的配置看起来正确。
欢迎就如何进行提出任何建议。
事实证明,答案实际上与服务 运行 下的帐户有关。按照 运行 windows 服务中命名管道端点的(不同的)教程,该服务被安装 运行 作为 NetworkService 服务帐户,它需要 运行 在 LocalSystem 帐户下才能正常工作。感谢 Tim 的建议。
我正在尝试使用 http 和命名管道端点构建 windows 服务托管的 WCF 服务。当我将它配置为使用命名管道时,它工作正常,但是当我尝试将它配置为使用 http 绑定时,它会全部编译和安装,但是当我尝试启动该服务时,它立即停止,我不能在事件查看器中找到一条错误消息。
这是我的 app.config 文件。注释里的配置有效,没有注释的配置无效
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config
file must be added to the host's app.config file.
System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="NogginWcf.NogginWcfSvc">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="" name="BasicHttp" bindingName="BasicHttp"
contract="NogginWcf.INogginWcfSvc" />
<endpoint address="mex"
binding="mexHttpBinding" bindingConfiguration="" name="HttpMex"
bindingName="HttpMex" contract="IMetadataExchange" />
<!--<endpoint address="" binding="netNamedPipeBinding"
bindingConfiguration="" name="NamedPipes" bindingName="NamedPipes"
contract="NogginWcf.INogginWcfSvc" />
<endpoint address="mex"
binding="mexNamedPipeBinding" bindingConfiguration="" name="NamedPipesMex"
bindingName="NamedPipesMex" contract="IMetadataExchange" />-->
<host>
<baseAddresses>
<!--<add baseAddress="net.pipe://localhost/NogginPipesService" />-->
<add baseAddress="http://localhost:8000/NogginHttpService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
This MSDN tutorial 演示了使用 windows 服务托管 http 端点,我认为我的配置看起来正确。
欢迎就如何进行提出任何建议。
事实证明,答案实际上与服务 运行 下的帐户有关。按照 运行 windows 服务中命名管道端点的(不同的)教程,该服务被安装 运行 作为 NetworkService 服务帐户,它需要 运行 在 LocalSystem 帐户下才能正常工作。感谢 Tim 的建议。