Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add WCF IncludeExceptionDetailInFaults to Endpoint behaviors?

how do i add IncludeExceptionDetailInFaults = true; to the below code. I need to get the details of the FaultException thrown by the web service. currently i am not getting any details back. It looks like the only thing i get back is the . any ideas?

c# code

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";
like image 786
Anthony Avatar asked Nov 23 '10 18:11

Anthony


1 Answers

I think you'll have to add a 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();
like image 145
as-cii Avatar answered Nov 04 '22 09:11

as-cii