在调用WCF的时候经常会被not Found 404 这样的异常信息搞得一头雾水,到底什么原因呢,WCF并没有返回给我们这里我提供一方法帮助把元凶找出来:
首先在WCF端要添加ServiceBehavior属性并设置IncludeExceptionDetailInFaults值为true
[ServiceBehavior(IncludeExceptionDetailInFaults=true)]
public class GuestService : IGuestService
其次在客户端在调用WCF服务的时候要添加
bool registerResult = WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
bool httpsResult = WebRequest.RegisterPrefix("https://", WebRequestCreator.ClientHttp);
这样元凶找到了。。。。。
浙公网安备 33010602011771号