0
我創建了一個休息WCF服務。服務本身工作正常。從本地主機瀏覽我可以調用所有功能。以下是合同和功能。REST WCF服務不返回響應
的問題是,當我嘗試使用db.savechanges保存()服務不返回響應。如果我註釋掉該行返回JSON響應。
難道我做錯了什麼在我的代碼?
[DataContract]
public class RouteObject{
public List<DetailRouteInfo>routeDetail {get; set;} /// this is Entity Model Class;
}
[OperationContract]
[WebGet(UriTemplate="GRDI?route={route}&cloc={cloc}", ResponseFormat=WebMessageFormat.Json)]
RouteObject GRDI(string route,string cLoc);
public RouteObject GRDI(string route, string cLoc) {
MapApiClient mClient = new MapApiClient();
Response mData= new Response();
var coord=route.Split('|');
RouteObject rObject = new RouteObject();
rObject.routeDetail = new List<DriverRouteInfo>(); ;
//this variable needs to updated later
//List<string> dummyCoord= new List<string>();
List<Task> wtask = new List<Task>();
mClient.getRouteData(coord.ToList(), (x) =>
{
mData = x;
},
(y) =>
{
wtask.Add(y);
}
);
if (wtask != null)
{
Task.WaitAll(wtask.ToArray());
wtask.Clear();
}
DriverRouteInfo droute=null;
// DO SOME MANIPULATION WITH THE DROUTE //
// THEN ADD LIST OF DROUTE INTO ROUTOBJECT.DETAILROUTE //
try
{
using (var db = new F2PDatabaseEntities())
{
UserInfo userinfo = db.UserInfoes.SingleOrDefault(u => u.UserId == 1);
//userinfo.DriverRouteInfoes = listRoute;
foreach(var dr in rObject.routeDetail){
userinfo.DriverRouteInfoes.Add(dr);
}
db.SaveChanges();
return rObject;
}
var check = droute.RouteId;
}
catch(SqlException ex) {
throw new FaultException(ex.Message); ;
}
}