【发布时间】:2011-09-22 01:11:56
【问题描述】:
当我尝试向我的 WCF service 发出 POST 请求时,我无法向 POST the service request 和 can't get response. 发出 POST 请求
我正在使用 WebHttpBinding 和我的 WCF service is hosted in Windows service 和 PORT 8181
WCF 服务方法:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/{cstid}/{deptid}/get/customer/?cstname={cstname}",
BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
Customer CustomerGet(string cstid, string deptid, string cstname);
JQuery POST 方法
jQuery.ajax({
type: 'POST',
url: 'http://localhost:8181/mysite/e48/91/get/customer/?',
dataType: 'json',
contentType: "application/json; charset=utf-8",
processData: false,
success: function (data) {
alert(data); // not getting anything :(
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('Error :' + textStatus);
}
});
谁能告诉我为什么我无法调用此服务以及如何解决此问题?
提前致谢!
【问题讨论】:
-
你在使用 firefox 和 firebug 吗?帖子是否显示在控制台中?响应是什么样的?
-
我没有答案,但这是否使用 WCF 的 REST 工具包?
-
在构造的 jquery 调用中缺少服务 url 的查询字符串是错字吗?
-
我认为跨域发布存在问题,因为我正在使用 localhost:8080 PORT 运行我的 MVC 站点,而我的 WCF 服务是使用 localhost:8181 PORT 托管的......知道我会怎么做解决这个问题?
标签: wcf jquery wcf-client jquery-post