1

我正在尝试在 appharbor.com 托管 WCF Web 服务 该服务在本地托管时按预期响应,但是在 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
4

2 回答 2

0

请检查您的构建状态和测试。如果您的一项测试失败,则无法部署该项目。

于 2012-05-05T16:25:11.513 回答
0

我遇到了 WCF 服务的元数据问题。但是能够使用 *.svc 位置看到 WCF 服务在那里。http://achiever.apphb.com/AchievementService/ [您的服务名称].svc是否适合您?

编辑:试试这个修复在 AppHarbor 上托管 WCF Web API 应用程序?

于 2012-06-16T18:45:37.060 回答