柳生飘絮 SupperSdr

知识在于积累
posts - 9, comments - 1, trackbacks - 0, articles - 16
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

调试WCF技巧

Posted on 2009-09-03 10:19 柳生飘絮 阅读(74) 评论(0) 编辑 收藏

在调用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);

这样元凶找到了。。。。。