【发布时间】:2012-06-14 03:32:43
【问题描述】:
我正在像这样从 Ajax 调用 .NET WCF 服务:
result = $.ajax({
type: "POST",
// async: false,
contentType: "application/json; charset=utf-8",
url: BaseUrl + "Services/YucataService.svc/SetGameStatusSecure",
data: "{'gameID':'" + gameID + "','pid':'" + pid + "','status':'" + newStatus + "','origStatus':'" + oldStatus + "'}",
dataType: "json",
timeout: 20000
});
服务器部分如下所示:
[OperationContract]
public void SetGameStatusSecure(int gameID, int pid, string status, string origStatus)
{
... magic stuff happens
}
效果很好。
现在,我想同步调用服务。我做的唯一改变是添加“async:false”。 调用返回状态 500(=内部服务器错误)。
我是否必须以不同方式配置 WCF 服务才能允许同步调用?
在切换到 WCF 之前,我使用 .asmx 服务进行同步调用,没有任何问题。
有什么想法吗?
【问题讨论】:
-
能打到后端吗,先试试在后端下断点,看看能不能打到断点。检查失败的地方
-
同步调用时不打断点。因此,WCF 在我的代码执行之前拒绝了调用。