Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF ExceptionShielding Error ID does not match up with handlingInstanceId passed to Handler

I have the following decorated on my service

<ExceptionShielding("MyExceptionPolicyName")> 

when a fault exception is thrown, my policy picks up the error and logs in just fine. It takes the handlingInstance Id and logs it along with the error for reference. What I'm noticing, is the Guid returned in the Fault "Error ID:" is different than that one passed into the handling instanceId.

I've also tried to decorate the operation like so

<FaultContract(GetType(ValidationFault))> 

but this produces the same results.

What I would like to do is some how capture that "Error ID:" passed back to the consumer so I can log it along with the exception. *addition info: the exception policy handler is a custom one that takes an exception, and logs it's various properties and data into a specific exception log db schema.

Anyone know how to accomplish this?

UPDATE: per @Jay Patel 's comment, I added this to my config to enable tracing

<system.diagnostics>     <sources>       <source name="System.ServiceModel"               switchValue="Information, ActivityTracing"               propagateActivity="true">         <listeners>           <add name="traceListener"               type="System.Diagnostics.XmlWriterTraceListener"               initializeData= "c:\Temp\Traces.svclog" />         </listeners>       </source>     </sources>   </system.diagnostics> 

I then executed a request to get a fault response shielded by exception shielding. The fault response string is formatted like so: "An error has occurred while consuming this service. Please contact your administrator for more information. Error ID: {GUID}"

I then viewed the trace log, and found no evidence of the GUID or this string.

Here is the pastebin link to the tracelog for anyone who cares to see an example of one when using ExceptionShielding.

UPDATE2:

Again, per @Jay Patel's comment, added this. I tried -1 and max int value for the maxMessageLog to ensure I'm getting the largest amount of data in that log.

<diagnostics>   <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="2147483647" /> </diagnostics> 

The log is not helpful. It includes nothing about anything even close to answering my question.

To clarify in case it's not clear above... I want to be able to capture the GUID after the "Error ID:" in the message back to the client so I can log it with the exception that is logged by the exception handler. This way clients can contact the "Administrator" as the message says with the Error ID, and actually be able to find something.

Here is the full trace enabled pastbin

like image 595
wakurth Avatar asked Apr 09 '13 21:04

wakurth


1 Answers

According to http://msdn.microsoft.com/en-us/library/ff649012.aspx:

You can also specify a Source of "{Guid}" to add the current Handling Instance ID to the Fault Contract property.

In your .config file:

<mappings>     <add source="{Guid}" name="HandlingInstanceId" /> </mappings> 

In your ValidationFault FaultContract:

[DataMember] public Guid HandlingInstanceId { get; set; } 

Note: The "{Guid}" source appears to be a special marker for the Handling Instance ID.

See also: http://entlib.codeplex.com/discussions/232049

And, the last 2 entries: http://entlib.codeplex.com/discussions/243558

like image 105
Daniel Holder Avatar answered Sep 22 '22 15:09

Daniel Holder