I'm following this post to implement a WCF rest service.
The example works fine until I make a copy of the PlaceOrder method and call it PlaceOrder2, and replace the data type of the order parameter from OrderContract Dictionary. When the method is invoked on the server, the order parameter is empty without any keys.
// Interface
[OperationContract]
[WebInvoke(
UriTemplate = "/PlaceOrder2",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
Method = "POST"
)]
bool PlaceOrder2(Dictionary<string, string> order);
// Implementation
public bool PlaceOrder2(Dictionary<string, string> order)
{
Console.WriteLine(order.Keys.Count); // 0 here
return true;
}
HTTP Request:
POST [this is not a link]http://localhost:53210/OrderService.svc/PlaceOrder2 HTTP/1.1
User-Agent: Fiddler
Content-Type: application/json; charset=utf-8
Host: localhost:53210
Content-Length: 22
{"test":"12345678"}
HTTP Response:
HTTP/1.1 200 OK
Server: ASP.NET Development Server/11.0.0.0
Date: Tue, 02 Dec 2014 17:24:15 GMT
X-AspNet-Version: 4.0.30319
Content-Length: 4
Cache-Control: private
Content-Type: application/json; charset=utf-8
Connection: Close
true