【发布时间】:2014-03-15 19:02:00
【问题描述】:
我有 WCF 应用程序,我使用控制台应用程序在本地托管它。我在下面添加了配置。
服务类
namespace InboundMessage.Service;
Operator: IOperator {
}
namespace InboundMessage.Service;
IOperator {
}
App.config
<configuration>
<system.web>
<compilation debug="true">
</compilation>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="meta">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="InboundMessage.Service.Operator" behaviorConfiguration="meta" >
<endpoint address="basic" binding="basicHttpBinding" contract="InboundMessage.Service.IOperator"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress = "http://X:Port/InboundMessage.Service/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Host Project 是一个控制台应用程序,它在我的本地计算机上构建和安装。 配置文件有服务的地址。
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="ServiceAddress" value="http://X:Port/InboundMessage.Service/"/>
</appSettings>
<system.webServer>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
我不断收到此服务的元数据发布目前已禁用。我的设置中是否缺少某些内容。感谢您的宝贵时间。
编辑
它似乎只有在我在主机配置中添加以下内容时才有效,但它似乎不是托管服务的正确方法。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="meta">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="InboundMessage.Service.Operator" behaviorConfiguration="meta" >
<endpoint address="basic" binding="basicHttpBinding" contract="InboundMessage.Service.IOperator"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
【问题讨论】:
-
如果您将“基本”附加到控制台应用程序配置中的 ServiceAddress 设置,如下所示:
<add key="ServiceAddress" value="http://X:Port/InboundMessage.Service/basic" /> -
它抛出 HTTP 400 错误请求。查看我对原始问题的编辑。
-
为什么不正确?你想达到什么目标?
-
我是 WCF 新手,但如果我错了,请纠正我。我的理解是,如果我在服务中有
标记,并且宿主项目配置在应用程序配置中有引用。托管服务应该足够了
标签: c# .net web-services wcf web-hosting