faultexception

FaultException.Detail coming back empty

一个人想着一个人 提交于 2019-12-09 16:28:53
问题 I am trying to catch a given FaultException on a WCF client. I basically need to extract a inner description from the fault class so that I can then package it in another exception for the upper layers to do whatever. I've done this successfully a number of time, what makes it different this time is that fault is declared as an array, as you can see from the service reference attribute declared on top of the method that throws the exception: [System.ServiceModel.FaultContractAttribute(typeof

Catching a Specific WCF FaultException

为君一笑 提交于 2019-12-05 13:32:31
A single tier application can distinguish exceptions by: Exception ex; if (ex is System.DirectoryServices.AccountManagement.PasswordException) ... where ex is just a generic exception. When you move to WCF for multi-tier, you lose all this and you need to use the FaultException mechanism. The problem is that I can't find any way to do the above. In my client I want to catch the FaultException types and then distinguish between them i.e. something like: catch (FaultException ex) { if FaultException is (PasswordExceptionFault) ... etc } Is there a way to do this? Otherwise I have to have many

WCF custom fault exception not caught correctly in client

此生再无相见时 提交于 2019-12-05 12:34:52
I'm trying to create some custom FaultException . I've made a DataContract class called CreateFault . [DataContract] public class CreateFault { private string report; public CreateFault(string message) { this.report = message; } [DataMember] public string Message { get { return this.report; } set { this.report = value; } } } I'm then throwing the fault in a service method. In IService1.cs [OperationContract] [FaultContract(typeof(CreateFault))] void TestFaultException(); and in Service1.cs public void TestFaultException() { throw new FaultException<CreateFault>(new CreateFault("CreateFault

WCF/WebService: Interoperable exception handling

烈酒焚心 提交于 2019-12-04 03:33:43
I understand that WCF will convert an exception into a fault and send it back as a SOAP message, but I was wondering if this is truly interoperable. I guess I'm having a tough time trying to figure out this possible scenario: Client (Java) calls a WCF Service (LoginService). Server checks for proper authorization, user authorization fails. Server throws an UnauthorizedAccessException. WCF converts this into a Fault somehow. (* - See Below As Well) Client has to be able to know how to read this Fault. I guess I'm just having a tough time understanding how this could still be interoperable

FaultException.Detail coming back empty

瘦欲@ 提交于 2019-12-04 02:40:30
I am trying to catch a given FaultException on a WCF client. I basically need to extract a inner description from the fault class so that I can then package it in another exception for the upper layers to do whatever. I've done this successfully a number of time, what makes it different this time is that fault is declared as an array, as you can see from the service reference attribute declared on top of the method that throws the exception: [System.ServiceModel.FaultContractAttribute(typeof(FaultClass[]), Action = "http://whatever/", Name = "whateverBusinessFault")] This is my code: try { //

client will not catch generic FaultException< T >, only FaultException

北城以北 提交于 2019-11-30 17:29:29
I've read all there is to read on this, but maybe I'm missing something (well, definitely I'm missing something otherwise it would be working already) I'm throwing some exception error inside my server business layer: public class RfcException : Exception { public RfcException(string _m, Exception _inner) : base(_m, _inner) { } public Dictionary<string, string> ExtendedProperties { get { return extendedProperties; } protected set { extendedProperties = value; } } private Dictionary<string, string> extendedProperties = new Dictionary<string, string>(); } which I leave unhandled in the service,

FaultException and custom exception WCF

风流意气都作罢 提交于 2019-11-29 11:13:30
I have a question on how to send a custom exception as FaultException. It works when I use a system Exception like ArgumentException, but if I change it to my custom exception "TestException" it fails. I can’t get the configuration for the service reference, when I try to add it. Works: [OperationContract] [FaultContract(typeof(ArgumentException))] [TransportChannel TestMethod (); public Void TestMethod() { throw new FaultException<ArgumentException>(new ArgumentException("test"), new FaultReason("test")); } Doesn’t work: [OperationContract] [FaultContract(typeof(TestException))]