返回文件的服务器端代码
\
答案 0 :(得分:0)
这是我最近为我为POS写的休息服务所做的。 (对于你实际使用的任何类,myErrorType只是一个虚拟...)
using (var response = request.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
var reply = reader.ReadToEnd();
myErrorType result = Newtonsoft.Json.JsonConvert.DeserializeObject<myErrorType>(reply);
return result.Status;
// do something with the results
}
}
要抛出自定义错误:
myErrorType errresponse = new myErrorType();//dummy class, create your own...
throw new WebFaultException<myErrorType>(errresponse, HttpStatusCode.BadRequest);