By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,963 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,963 IT Pros & Developers. It's quick & easy.

WCF: Question about the right usage of FaultReason and FaultCode

P: n/a
Hi,

To protect my WCF service boundaries, I assign a unique support ticket to
all server side exceptions, log them and send a general FaultException to
client that only include the support ticket.

Support ticket is just a GUID that comes along with the exception log at the
server side.

From WCF programming best practice, What would be the best way to send the
support ticket to client? At this point my WCF services send this
FaultException to client:

FaultException fe = new FaultException(new FaultReason(ticket), new
FaultCode("LoggedServerException"));

Is this the recommended use of FaultReason and FaultCode? Should I consider
another way to send the ticket# to client application?

Any help would be appreciated,
Max
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Max,

Regarding on the FaultException in WCF, the document suggest that we define
a custom type which will wrapper all the information that may need to be
carried in the exception(send from server to client) and declare the
"FaultExceptionAttribute" on the certain interface which will throw this
exception(contains that custom type object). e.g.

#here [YourCustomType] is the custom type(should be serializable) you
defined(you may embed the guid or other data info in it)
==============
[OperationContract]
[FaultContractAttribute( typeof( YourCustomType ), ....... )]
string SampleMethod(string msg);
===========

this will make the service description(metadata) expose the information of
this exception. see the following document, it recommend that you define a
custom type instead of directly using a simple type(such as string):

#FaultException<(Of <(TDetail>)>) Generic Class
http://msdn.microsoft.com/en-us/library/ms576199.aspx

And here are some other web articles which also mentioned the usage of the
FaultException :

#[WCF] Fault contracts
http://bloggingabout.net/blogs/jpsmi...ault-contracts
.aspx

#WCF FaultException * why use it?
http://dotnet.org.za/willy/archive/2...on-_2620_-why-
use-it_3F00_.aspx
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: "Max2006" <al*******@newsgroup.nospam>
Subject: WCF: Question about the right usage of FaultReason and FaultCode
Date: Wed, 25 Jun 2008 16:29:25 -0400

Hi,

To protect my WCF service boundaries, I assign a unique support ticket to
all server side exceptions, log them and send a general FaultException to
client that only include the support ticket.

Support ticket is just a GUID that comes along with the exception log at
the
server side.

From WCF programming best practice, What would be the best way to send the
support ticket to client? At this point my WCF services send this
FaultException to client:

FaultException fe = new FaultException(new FaultReason(ticket), new
FaultCode("LoggedServerException"));

Is this the recommended use of FaultReason and FaultCode? Should I consider
another way to send the ticket# to client application?

Any help would be appreciated,
Max

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.