Getting POST or PUT to work in WCF REST service

I have a WCF service and I can get from it, but I can’t figure out how to do this. I just want to increase the hit field every time a record is used in the client. Here is my code.

Interface:

[OperationContract]
[WebInvoke(Method = "PUT",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.Wrapped,
    UriTemplate = "IncSMS")]
void IncSMS();

Method:

public void IncSMS()
{
    var business =
        (from p in _db.Businesses
            where p.BusinessID == 1
            select p).FirstOrDefault();
    business.SMSHits += 1;
    _db.SaveChanges();
}

I get "Method Not Allowed". In IE, can anyone see what Im doing wrong ???

Greetings

Mike.

+5
source share
3 answers

Well, I asked a question, and it took me three days to find the answer to something that was supposed to be very simple.

So the question is over: How to add a title Content-Lengthto my request ???

: Content-Length URI ", GET"!!! Content-Length , , , Fiddler - !

Content-Length: 0 " " " ", ! : http://blog.donnfelker.com/2008/12/04/how-to-rest-services-in-wcf-3-5-part-2-the-post/

, ,

.

+7

, , , HTTP, , WCF. PUT HTTP- WCF -exposed. , HTTP POST, PUT.

Fiddler, . , , , POST, :

HTTP/1.1 405 Method Not Allowed
Allow: PUT
Content-Length: 1565
Content-Type: text/html; charset=UTF-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Thu, 10 Nov 2011 02:17:43 GMT

"" : PUT.

+2

PUT, Fiddler, HTTP, , .. WCF.

0

All Articles