[英]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.