1
有人可以告诉我如何配置WCF端点以便从JQuery Ajax调用中调用以下RESTful Web服务。我的例子服务代码:如何为客户端jQuery调用配置WCF RESTful端点
namespace MyService
{
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service
{
[OperationContract]
[WebGet(UriTemplate = "/GetDepartment")]
public Department GetDepartment()
{
... code
};
return data;
}
}
jQuery代码:
var jData = {};
$.ajax({
cache: false,
type: "POST",
async: true,
url: "MyService/GetDepartment",
data: JSON.stringify(jData),
contentType: "application/json",
dataType: "json",
success: function (jsondata) {
... code
},
error: function (xhr) {
alert(xhr.responseText);
}
});
谢谢您的答复。我需要的是Web.config端点配置设置。示例: – 2015-03-02 12:06:57
太棒了!你的问题现在解决了吗? – 2015-03-02 12:30:10