WCF未找到终结点?
其实服务可以用,但是不能传递参数。不知道为什么。
web.config中endpoint的behavior用的webhttp
[WebGet(RequestFormat=WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
[OperationContract]
public NewsModel newsdetail(int id) //请求:http://127.0.0.1/dtsrv.svc/newsdetial/1提示未找到终结点,但是如果直接请求..../newsdetail就能输出(当然了输出的是null字符串)
{
return newsService.GetNews(id);
}
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
[OperationContract]
public NewsModel[] newslist() //这个没有参数,直接请求dtsrv.svc/newslist输出正常。
{
//..........
return ret;
}
请问为什么呢? 这个id这个参数要怎么传递? 是我请求方式有问题吗? WCF? 未找到终结点
[解决办法]
http://127.0.0.1/dtsrv.svc/newsdetial?id=1
[解决办法]
复杂类型就必须用POST的方式传递Json了