【发布时间】:2012-05-14 21:02:55
【问题描述】:
我正在尝试在 appharbor.com 上托管 WCF 网络服务 该服务在本地托管时按预期响应,但在 appharbor 构建和托管时,它只返回 404。
服务正在控制台应用程序中运行:
namespace Service.Host
{
class Program
{
static void Main(string[] args)
{
var host = new ServiceHost<AchievementService>();
host.Open();
Console.WriteLine("AchievementService is running...\nPush any key to terminate.");
Console.ReadLine();
host.Close();
}
}
}
app.config 如下所示:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="Service.Main.AchievementService">
<host>
<baseAddresses>
<add baseAddress="http://achiever.apphb.com"/>
<!--<add baseAddress="http://localhost"/>-->
</baseAddresses>
</host>
<endpoint address="AchievementService/"
behaviorConfiguration="RestBehavior"
binding="webHttpBinding"
contract="Service.Main.Contracts.IAchievementService"/>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestBehavior">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
如果我使用包含值“http://localhost”的基地址,我可以在我的 web 服务中访问 get 方法、元数据、帮助等。但是当我将其更改为成就者.apphb.com 并构建它时,我只能在 http://achiever.apphb.com/AchievementService/ 或 http://achiever.apphb.com/ 收到 404
我尝试过的是各种地址配置,我尝试过在 appharbor 构建的 localhost,结果相同。我也搜索了一些例子,但我没有找到任何可以帮助我解决这个问题的东西。
服务已部署,不包含任何测试,来自 appharbor 的注释:
5/5/12 6:02 PM: Received notification, queuing build
5/5/12 6:02 PM: Downloading source
5/5/12 6:02 PM: Downloaded source in 0.27 seconds
5/5/12 6:02 PM: Starting build
5/5/12 6:02 PM: 0 warnings
5/5/12 6:02 PM: Build completed in 1.57 seconds Details
5/5/12 6:02 PM: Starting website precompilation
5/5/12 6:02 PM: Precompilation completed
5/5/12 6:02 PM: Starting tests
5/5/12 6:02 PM: Tests completed in 2.39 seconds
5/5/12 6:02 PM: Build successfully deployed
Tests
Build contains no tests
【问题讨论】:
-
构建成功了吗?
-
是的,我已经更新了问题以反映这一点。不过好点
-
我唯一能做的就是您的 WCF 主机没有配置适当的端点。我知道你有一个
app.config,但这并不意味着它对主机来说是正确的。 -
据我了解,端点配置是如何访问网络服务。您能否详细说明何时配置了适当的端点?每个端点都应该是可访问的。
-
WCF 服务必须由某些东西托管。对于 appharbor,我假设它是某种 IIS 配置。
标签: c# wcf app-config appharbor wcf-endpoint