Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6105925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:01:28+00:00 2026-05-23T14:01:28+00:00

I am working on a client that is consuming a WCF service. In various

  • 0

I am working on a client that is consuming a WCF service. In various cases, the service simply raises a FaultException with an associated message informing of the reason behind the given fault.

Some of these faults are things that can be handled by our client application, but I’m hesitant to simply try and perform some string matching on the FaultExceptions Message or Reason to determine if it is something we can cater for or not.

I was hoping that the FaultCode on FaultException could be used to identify a specific type of Fault that we could handle, but it seems that this is purely to identify a handful of SOAP faults. Please correct me if my interpretation of this is incorrect.

I know that it could be that a FaultException could be raised, but I feel it is unrealistic to expect that a new type should be created for each reason behind a fault.

How do you handle this situation. As a contrived example. Consider a service that provides the following methods;

RecordDetails GetRecordById(string id)

void Add(RecordDetails record)

void Update(RecordDetailsUpdateRequest rdur)

Now in the example above, if you call GetRecordById with an id that doesn’t exist, you receive a FaultException with a Message stating “Record cannot be found”. Similarly, if you call Add for a record that already exists, or Update for a record that doesn’t exist, you simply get a FaultException with a Message/Reason detailing the reason for failure. I need to know if a record exists or not to determine whether I should update or insert. As I mentioned, I’m hesitant to simply match on strings as I have no control over whether they will remain the same or not.

What would you expect in this situation (a type associated with the FaultException detailing RecordNotFoundException etc) or some generic type associated with FaultException that defines specific details relating to the error. For example, a RecordOperationExcpetion class with members Code (a constant or enum identifier of the reason for failure), along with a user friendly message.

At least this way, I could identify the error cause without having to resort to string matching.

Your thoughts are appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:01:29+00:00Added an answer on May 23, 2026 at 2:01 pm

    I would go with what you said above – a type associated with the FaultException. You can create any number of classes represented as a DataContract to handle various faults, and then assign them to the WCF Service operations.

    [DataContract]
    public class RecordOperationException
    {
        private int code;
        private string message;
    
        [DataMember]
        public int Code
        {
            get
            {
                return code;
            }
            set
            {
                code = value;
            }
        }
    
        [DataMember]
        public string Message
        {
            get
            {
                return message;
            }
            set
            {
                message = value;
            }
        }
    }
    

    Then you can assign the this class as a FaultException:

    [OperationContract]
    [FaultContract(typeof(RecordOperationException))]
    RecordDetails GetRecordById(string id)
    
    [OperationContract]
    [FaultContract(typeof(RecordOperationException))]
    void Add(RecordDetails record)
    
    [OperationContract]
    [FaultContract(typeof(RecordOperationException))]
    void Update(RecordDetailsUpdateRequest rdur)
    

    You can then throw the appropriate FaultException in your methods, as desired.

    This will eliminate the need to compare strings (which is a good idea, IMO).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a client app that uses a restful service to look up
I have a WCF service that has been working perfectly, and something has changed
I'm working with a client that needs to generate millions of the alphanumeric codes
We are working on a website for a client that (for once) is expected
I am working on a client-server application that uses boost::serialization library for it's serialization
Folks, I'm working on a little piece of rich client software that I'd like
I have a SOAP client in Ruby that I'm trying to get working with
Environment I'm working on a C++ application that uses SQL Native Client 9.0 to
We're working on a rich client (written in Flex) that is connected to a
I am working with an application that is used by multiple clients. Each client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.