死简单的 WCF - 405 方法不允许

Dead simple WCF - 405 Method not allowed

据我所知我已经模仿了this post and this post接受的解决方案。除非我是盲人(我希望我在这一点上是盲人),否则我的非常简单的 WCF 服务一尘不染 app.config

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="RESTBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>
<services>
  <service name="Vert.Host.VertService.RSVPService">
    <endpoint
      address="/RSVP"
      binding="webHttpBinding"
      contract="Vert.Host.VertService.IRSVP"
      behaviorConfiguration="RESTBehavior" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/Vert" />
      </baseAddresses>
    </host>
  </service>
</services>
</system.serviceModel>

这是相应的服务契约和实现:

namespace Vert.Host.VertService
{
    [ServiceContract]
    public interface IRSVP
    {
        [OperationContract]
        bool Attending();

        [OperationContract]
        bool NotAttending();
    }

    public class RSVPService : IRSVP
    {
        public bool Attending()
            return true;

        public bool NotAttending()
            return true;
    }
}

我通过控制台应用程序托管所有内容:

class Program
{
    public static void Main()
    {
        // Create a ServiceHost
        using (ServiceHost serviceHost = new ServiceHost(typeof(RSVPService)))
        {
            serviceHost.Open();
            // The service can now be accessed.
            Console.ReadLine();
        }
    }
}

我只想启动这个小服务,但我无法使用 http://localhost:8080/Vert/RSVP/Attending 访问此端点。我仍然 405 Method not allowed 作为 response.I' 使用 Visual Studio Community 2015,IIS10,目标 .NET 4.6

我根据建议尝试过的事情:

我错过了什么?

老实说,我不确定这是否会有所作为,但我的 link 服务行为。为您的服务行为命名:

<serviceBehaviors>
    <behavior name="ServiceBehavior">

然后link为您服务:

<service name="Vert.Host.VertService.RSVPService" behaviorConfiguration="ServiceBehavior">

务必使用 [WebGet] 属性修饰服务方法(参考 System.ServiceModel.Web.dll

即从

更改服务
public class RSVPService : IRSVP
{
    public bool Attending()
        return true;

    public bool NotAttending()
        return true;
}

public class RSVPService : IRSVP
{
    [WebGet]
    public bool Attending()
        return true;

    [WebGet]
    public bool NotAttending()
        return true;
}

问题已解决。