[英]WCF Web Service Not Working
我有一个名为“ WebMethods”的WCF服务。 下面是我的代码。
在IWebMethods.cs中:
[ServiceContract(Name = "WebMethods")]
public interface IWebMethods
{
[OperationContract]
[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
String Test();
}
在WebMethods.cs中:
public class WebMethods : IWebMethods
{
public String Test()
{
return "This is a test YEAH!!";
}
}
和调用javascript:
$.ajax({
url: 'WebMethods.svc/Test',
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: null,
async: false,
success: function (data) {
alert(data);
},
error: function (xhr, textStatus, errorThrown) {
alert(errorThrown);
}
});
当我执行我的JavaScript时,出现错误“内部服务器错误”。 有人可以告诉我我做错了什么,或者至少我可以做些什么来解决此问题?
那么您的web.config文件呢? 尝试导航到您的服务页面,也许它可以为您提供有关该错误的更多说明。 上面的代码似乎还可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.