Anthony
Anthony

Reputation: 536

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";

Upvotes: 6

Views: 5020

Answers (1)

as-cii
as-cii

Reputation: 13019

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();

Upvotes: 5

Related Questions