WCF Web服务不工作

问题描述:

我有一个名为“WebMethods”的WCF服务。以下是我的代码。WCF Web服务不工作

在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我得到的错误“内部服务器错误”。有人可以告诉我我做错了什么,或者至少我能做些什么来解决这个问题?

+0

您能提供比'内部服务器错误'更多的日志吗? – fmgp 2012-04-20 17:35:45

+0

@fmgp,这是服务返回的唯一错误。有什么地方可以查找更详细的错误消息吗? – Coltech 2012-04-20 17:37:39

+0

您可以直接导航到您的服务页面吗? – 2012-04-20 17:49:37

你的web.config文件怎么样?尝试导航到您的服务页面,也许它可以给你更多关于错误的解释。上面的代码似乎没问题。