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

被折叠的 条评论
为什么被折叠?



