我有 wcf 之类的方法
void finalize(string jsonstring);
我使用像 finalize/{json} 这样的请求 url
但是如果尝试用 json 调用它,它会给出错误的请求原因,例如:等等
如何解决这个问题
这是我用于该方法的代码
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
UriTemplate = "FinalBooking/{BookingJsonString}")]
public int Finalize(string JsonString)
{
int result; // 1 success , 0 faill
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
Routess routes =
(Routess)json_serializer.DeserializeObject(JsonString);
using (XEntities context = new XEntities())
{
result = context.usp_Final(routes.TypeID, routes.regID, routes.CycleID, routes.DateTime,
routes.LocationID, routes.PatID, routes.PO, routes.BTID, routes.DID);
}
return result;
}
}
数据示例是简单的 JSON 字符串,例如
{"DateTime":"03/09/2012 09:00","CycleID":6,"BTID":31,"DiseaseID":814,"LocID":36,"PatID":13,"PO":1,"TypeID":744,"rID":-1}
此致