【发布时间】:2013-02-06 09:31:57
【问题描述】:
我一直在为这个问题头疼,但我就是找不到问题所在。 我在 WCF 服务方面没有太多经验,所以我希望它可能是我错过的一些简单的东西。
我已经设置了这个 WCF OData 服务,像这样公开我们的实体模型:
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
现在我一直在使用 jQuery 毫无问题地访问该数据,但是一旦我更新了我获取的 jsonp 对象,并将其放回服务以更新数据库,我将返回一个 HTTP 501 代码(未实施)。
这是我编写的将对象放回服务的代码:
function commitData() {
$.ajax({
url: 'http://localhost:7634/API/Service.svc/tbl_bericht_vertalingen/?$format=json&Authorization=' + userGuid,
contentType: 'application/json',
type: 'PUT',
data: jsonObject,
dataType: 'json',
error: function () { alert("oops!"); },
success: updateCallback
});
}
function updateCallback(result) {
var record = result["d"];
alert("Updated on record with ID " + record.Id);
}
jsonObject 与我之前从服务中收到的对象相同,具有一些更新的属性。
如前所述,调用这段 jQuery 会导致我从服务中返回“501 - 未实现”。
任何帮助将不胜感激。
【问题讨论】:
-
每当您从 WCF 数据服务中获取错误代码时,请考虑使用 this 博客文章中的步骤来获取有关正在发生的事情的更多上下文。
标签: jquery wcf-data-services odata put