WCF REST - 405 Method Not Allowed
-
Wednesday, November 02, 2011 3:19 PM
I have a RESTFul web service that exposes GET, POST and DELETE methods on a single interface (see below). This is self hosted using WebServiceHost.
I have a client that derives from ClientBase and that uses the exact same interface as exposed by the service.
Running the service locally I can use fiddler to access each of the functions without issue.
In a simple test application I access service using the client and again I can access each of the functions without issue.
However, In my production application (another self hosted webservice) I try to use the exact same client and I get a 405 - Method Not Allowed when calling the DELETE function (POST works fine, I don't use GET). From the WCF logs it appears as though the verb has been changed to POST instead of DELETE. I have no idea what might be causing this behaviour and have run out of ideas as to where to look and what to investigate.
Help!
[ServiceContract] public interface ITradeIO { [OperationContract] [WebGet(UriTemplate = "/trades/{identId}")] TradeData ReadTrade(string identId); [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "/trades")] TradeResponseCollection ImportTrade(TradeData trade); [OperationContract] [WebInvoke(Method = "DELETE", UriTemplate = "/trades/{identId}")] ResponseCollection DeleteTrade(string identId); }Client
public class TradeIOClient : ClientBase<ITradeIO>, ITradeIO { }Client Config
<system.serviceModel> <client> <endpoint address="http://localhost:8090/InterfaceService/TradeIO/" behaviorConfiguration="webHttpBinding_ITradeIO" binding="webHttpBinding" bindingConfiguration="webHttpBinding_ITradeIO" contract="InterfaceService.ITradeIO" name="RESTfulImport" /> </client> <behaviors> <endpointBehaviors> <behavior name="webHttpBinding_ITradeIO" > <webHttp /> </behavior> </endpointBehaviors> </behaviors> <bindings> <webHttpBinding> <binding name="webHttpBinding_ITradeIO" /> </webHttpBinding> </bindings> </system.serviceModel>
- Edited by Ferno70 Wednesday, November 02, 2011 3:22 PM
All Replies
-
Wednesday, November 02, 2011 3:39 PM
This could be caused by WebDAV Module in IIS:
According to a post on IIS.net (http://forums.iis.net/t/1176772.aspx), you could try adding the following to your web.config:
<system.webServer> <modules> <remove name="WebDAVModule" /> </modules> </system.webServer>
-
Wednesday, November 02, 2011 4:38 PMYes, I've read various articles mentioning issues caused by WebDAV, however, I've checked and WebDAV is not installed. Besides, wouldn't this also affect access via Fiddler etc?
-
Wednesday, November 02, 2011 4:57 PM
Found the solution from this post:
- Marked As Answer by Ferno70 Wednesday, November 02, 2011 4:57 PM

