none
WCF REST - 405 Method Not Allowed

    Question

  • 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
    Wednesday, November 02, 2011 3:19 PM

Answers

All replies