Ant*_*ony 6 c# wcf wcf-binding
我如何添加IncludeExceptionDetailInFaults = true; 到下面的代码.我需要获取Web服务抛出的FaultException的详细信息.目前我没有收到任何细节.看起来我唯一能回来的就是.有任何想法吗?
c#代码
CustomBinding Binding = new CustomBinding(BINDING_NAME);
EndpointAddress EndPoint = new EndpointAddress(WsEndpoint);
// Trust all certificates
ServicePointManager.ServerCertificateValidationCallback = ((Sender, certificate, chain, sslPolicyErrors) => true);
_WsProxy = new MyDataSoapClient(Binding, EndPoint);
//_WsProxy.Endpoint.Behaviors.Add(????);
_WsProxy.ChannelFactory.Credentials.UserName.UserName = "username";
_WsProxy.ChannelFactory.Credentials.UserName.Password = "pwd";
Run Code Online (Sandbox Code Playgroud)
我想你必须添加一个ServiceDebugBehavior.
ServiceHost host = new ServiceHost(typeof(MyService), new Uri("http://localhost:6598/"));
host.AddServiceEndpoint(typeof(IMyService), new BasicHttpBinding(), "MyService");
host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior));
host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
host.Open();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4572 次 |
| 最近记录: |