【发布时间】:2012-10-04 13:37:22
【问题描述】:
嘿嘿,
我觉得自己像个白痴,但我似乎找不到答案。
我在控制台应用程序中自托管 WCF 服务。 这就像一个魅力,我已经做了一百万次了:)
从另一个控制台应用程序或使用 wcftestclient 使用此服务完全没有问题。
但是当我尝试浏览服务时,我得到了“奇怪”的行为。
服务托管在http://localhost:50666/MyService.Foo/BarServiceHttp(基地址为http://localhost:50666/MyService.Foo)。
因此,当浏览到 http://localhost:50666/MyService.Foo/BarServiceHttp 时,浏览器会返回 HTTP 400 错误。
浏览基地址会得到我期望的完整地址的输出。
发生了什么事? (http后面的空格是为了绕过关于localhost的警告...)
这是服务器配置:
<service name="FooService" behaviorConfiguration="FooBarServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:50666/MyService.Foo" />
</baseAddresses>
</host>
<endpoint address="BarServiceHttp"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfiguration"
contract="IBarService" />
<endpoint address="BarServiceHttp/mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
<behavior name="FooBarServiceBehavior">
<!-- Enable MEX http get for this service. -->
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
【问题讨论】:
-
@CodeCaster 该设置在绑定配置中不可用。它是在我的服务行为配置中设置的,但我已将其排除在外,将调整有问题的服务器配置。
标签: wcf self-hosting