我一直在为这个问题烦恼,而我无法发现问题。 我对WCF服务没有太多的经验,所以我希望这可能是我错过的简单东西。将数据发布到来自JQuery的WCF OData服务
我已经建立了这个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]中的步骤(http://blogs.msdn.com/b/phaniraj/archive/2008/06/18/debugging-ado-net-data-services.aspx)博客文章,以获得更多关于发生了什么的上下文。 –