在基于IIS中的基于WCF Rest的服务中,出现以下问题。WCF REST和IIS Express 7.5返回请求错误(400)
接口:
[ServiceContract]
public interface ITestService
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/GetEmployee/{userid}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,BodyStyle=WebMessageBodyStyle.Bare)]
IEnumerable<Employee> GetPlans(string userid);
}
TestService.svc.cs:
public class TestService : ITestService
{
public IEnumerable<Employee> GetEmployee(string userid)
{
return Employee
}
}
当我使用卡西尼服务器,它工作在JSON格式精细returnштп结果。网址如下:
http://localhost:58764/TestService/TestService.svc/GetEmployee/2
但是当我主持,在IIS快递7.5在URL:
http://localhost/TestService/TestService.svc/GetEmployee/2)
它只是说:
“请求错误
服务器在处理请求时遇到错误,请参阅服务帮助页面,以便为服务构建有效的请求。“
但
http://localhost/TestService/TestService.svc/help
返回所有可用的方法没有任何问题的URL。
您确定Employee对象是可序列化的吗?有时通过cassini的序列化通过,但在IIS上托管时失败。在IIS上托管时,请尝试在您的服务上启用跟踪,以获取您的请求失败原因的确切原因。可能是由于返回的数据大小所致 – Rajesh 2012-03-16 09:00:22