English 中文(简体)
Fiddler根据要求向WCF Service PUT/POST发放411份通行证
原标题:Fiddler gives 411 Error on request to WCF Service PUT/POST

当我向以下各方发出请求时,我已经犯了411个错误:

接口:

[OperationContract]
[WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.Wrapped,
    UriTemplate = "IncSMS")]
string IncSMS(int ID);

方法:

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

谁能看到我为什么会犯错误? 所有的得力方法工作,我只得获得POST或PUT服务!

任何想法?

Cheers,

Mike。

最佳回答

这部法典没有任何错误,我试图通过浏览器申请PUT,而不能这样做。 你们可以以这种方式而不是PUT的方式测试GETs。 “由于违约,它将履行GET”!

在请假中,你只是“重建者”“要求负责人”一节中的“准则”栏目中的“条码”0http://blog.donnfelker.com/2008/12/04/how-to-rest-services-in-wcf-3-5-part-2-the-post/

感谢gu,

Mike。

问题回答

According to the HTTP Standards, 411 means: 10.4.12 411 Length Required

The server refuses to accept the request without a defined Content- Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message-body in the request message.

因此,请您通过POST/PUT补充数据,说明数据长度。

POST and PUT operations in WCF REST services require that a Content-Length header be included. The 411 response code is WCF telling you to include that header.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签