2

As far as I can tell I have mimicked the accepted solutions of this post and this post. Unless I'm blind (and I hope I am at this point), I have a spotless app.config for my very simple WCF service:

<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> 

Here's the corresponding Service Contract and Implementation:

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; } } 

I'm hosting everything via a console app:

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(); } } } 

All I want to do is stand this tiny service up, but I can't hit this endpoint with http://localhost:8080/Vert/RSVP/Attending. I still get 405 Method not allowed as a response.I'm using Visual Studio Community 2015, IIS10, targeting .NET 4.6

Things I've tried from suggestions:

  • I've given my service an explicitly-named behavior. No luck.

What am I missing?

2 Answers 2

0

Honestly not sure if this will make the difference, but mine has a link to service behaviour. Give your service behaviour a name:

<serviceBehaviors> <behavior name="ServiceBehavior"> 

Then link it to your service:

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

Sign up to request clarification or add additional context in comments.

2 Comments

First thing I tried post-posting this post. No luck :(
Don't know then. I largely got mine working through blind luck. I can only recommend turning on logging, see this post.
0

Be sure to decorate the service methods with the [WebGet] attribute (reference System.ServiceModel.Web.dll)

I.e. changing the service from

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

to

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

Solves the issue.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.