0
这里是我试图从我的WCF服务调用DELETE方法:呼叫从客户端应用程序了删除WCF RESTful服务的方法
string tmpUrl1 = "http://localhost:1234/MyService.svc/EndPoint/MyMethod";
WebRequest request1 = WebRequest.Create(tmpUrl1);
request1.Method = "DELETE";
byte[] byteArray1 = Encoding.UTF8.GetBytes("{\"idName\":" + newIdName + "}");
request1.ContentType = "application/json";
request1.ContentLength = byteArray1.Length;
Stream dataStream1 = request1.GetRequestStream();
dataStream1.Write(byteArray1, 0, byteArray1.Length);
dataStream1.Close();
WebResponse response1 = request1.GetResponse();
,但我得到错误400
这里是方法的名称在wcf:
[OperationContract]
[WebInvoke(
Method = "DELETE",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/MyMethod/{deleteRP}/",
BodyStyle = WebMessageBodyStyle.Bare
)]
MyClass MyMethod(string deleteRP);
我在哪里犯了一个错误?
好byteArray1是给的链接 – 2012-01-12 12:48:28
我猜“55”的部分有当其试图反序列化字节组被张贴在服务器上的问题。请找到序列化请求的代码。希望能帮到你 – Rajesh 2012-01-12 13:09:02
我使用相同的代码来调用POST方法(而不是DELETE,我把POST)并且一切正常。所以不是这样。 – 2012-01-12 13:11:50