我是 WCF Web 服务的新手,不太了解如何调试 Web 服务...
以下示例,我创建了一个具有如下界面的 Web 服务:
public interface IMyService
{
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
List<MyClass> GetData(string param);
}
以及返回 MyClass 列表的实现。
部署后,我在 Fiddler 中调用了该服务,例如
http://localhost/MyService.svc/GetData?keyword=blabla
它返回:
HTTP/1.1 401 Unauthorized
Server: Microsoft-IIS/7.5
SPRequestGuid: blabla
WWW-Authenticate: blabla
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 14.0.0.6114
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Date: Mon, 12 Nov 2012 17:24:08 GMT
Content-Length: 0
如果我只是写在作曲家:
http://localhost/MyService.svc/GetData
如果没有参数,它会返回状态为 200 的空 json。
当我在 Chrome 中尝试第一个请求时,它连续向服务器要求我的用户名和密码,但输入它们并没有帮助我摆脱循环(要求用户名和密码)。
有没有人遇到过这样的问题?或者你能对调试有什么建议吗?