Geeks With Blogs

News This is the *old* blog. The new one is at blog.sixeyed.com
Elton Stoneman
This is the *old* blog. The new one is at blog.sixeyed.com

[Source: http://geekswithblogs.net/EltonStoneman]

The management portal for ESB Guidance is an excellent tool which displays information on faults generated during the processing of messages through the ESB. It also exposes Web and WCF services for logging your own faults to the exception database, so you can record exceptions that occur in your own service providers and use the portal as a single view over the health of your SOA stack.

The SubmitFault method of the ExceptionManagement service takes a FaultMessage object which must be correctly configured with Header and FaultException properties. It takes some trial-and-error to work out what needs populating – if any properties are missing or invalid, your fault won't be logged. I've put together a sample error handler on MSDN Code Gallery which populates a call correctly: ESB Guidance Error Handler, which you can use as-is in your WCF services, or as a basis for your own handler.

In the sample, the error handler is available to your service so you can manually log a fault for any exceptions that you catch, and you can also configure it as a service behaviour so it will log any uncaught exceptions in your WCF service. A sample service and client are provided for demonstration – set up the SampleService as a virtual directory and run SampleClient (you'll need the ESB Guidance Exception Management installed).

To use the ServiceProviderErrorHandler add a config section in your web.config to specify how faults are logged:

    <configSections>

    <section

name="serviceProviderErrorHandlerConfiguration"

type="ESBGuidanceErrorHandler.Configuration.ServiceProviderErrorHandlerConfiguration, ESBGuidanceErrorHandler"/>

    </configSections>

    <serviceProviderErrorHandlerConfiguration

exceptionHandlingUrl="http://localhost/ESB.ExceptionHandlingServices/ExceptionHandling.asmx"

bizTalkApplication="BizTalk Application 1"

faultCode="50054"

errorType="Service Provider exception"

failureCategory="0"

faultGeneratorName="ESBGuidanceErrorHandler">

    </serviceProviderErrorHandlerConfiguration>

This identifies the location of the ExceptionHandling service (the sample uses the SOAP entry point, but it's a simple change to use the WCF version as they have the same signature) and the descriptive text to categorise errors being logged, which will be shown in the portal. Note that the specified BizTalk Application must exist and the fault generator name is limited to 50 characters. Other values can contain any identifiers you like.

With the config specified, it's a simple call to log a fault – passing the name of the service provider and the service, description and severity of the fault, and an exception:

ServiceProviderErrorHandler.SubmitFault("ErroringService", "LogHandledException", "Caught exception", FaultSeverity.Error, ex);

To register the ServiceProviderErrorHandler to catch any unhandled exceptions that occur just requires a behaviour extension in the WCF service configuration:

    <system.serviceModel>

        <services>

            <service name="ErroringService" behaviorConfiguration="defaultServiceBehavior">

                <endpoint contract="IErroringService" binding="basicHttpBinding"/>

            </service>

        </services>

        <behaviors>

            <serviceBehaviors>

                <behavior name="defaultServiceBehavior">

                    <serviceMetadata httpGetEnabled="true"/>

                    <serviceDebug includeExceptionDetailInFaults="true"/>

                    <serviceProviderBehavior/>

                </behavior>

            </serviceBehaviors>

        </behaviors>

        <extensions>

            <behaviorExtensions>

                <add name="serviceProviderBehavior" type="ESBGuidanceErrorHandler.Behaviors.ServiceProviderBehavior, ESBGuidanceErrorHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=de4c0bb04730ca55"/>

            </behaviorExtensions>

        </extensions>

    </system.serviceModel>

Add this to all your WCF service providers and any exceptions will be logged and can be shown, filtered and subscribed to in the normal way.

Posted on Tuesday, January 20, 2009 8:43 AM ESB Guidance , WCF , Code Gallery | Back to top


Comments on this post: Generic WCF Error Handler for ESB Guidance

# USANA
Requesting Gravatar...
Great post containing some creative ideas.Thanks for posting.Keep it up
Left by skin-care on Apr 10, 2010 7:20 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article.
Left by ipad scrapbook app on Sep 28, 2010 7:14 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
Really impressed! Everything is very open and very clear explanation of issues. It contains truly information. Your website is very useful. Thanks for sharing. Looking forward to more!
Left by St Pierre Koscheck Fight Video on Dec 11, 2010 6:08 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
Do you have a documentation on these?This is a good source.It seems it doesn't work for us.
Left by well on Jan 14, 2011 3:25 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...

This is a great blog with excellent posts and links.
Thanks for sharing.
Left by florist France on Mar 12, 2011 7:38 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
having it large there
Left by pet sitting charlotte nc on May 14, 2011 12:02 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
great help this was
Left by celebrity news today on May 14, 2011 12:03 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
Trial and error can be minimized by using your formula. This formula will be very helpful for newbies like me.
Left by online high school classes on May 19, 2011 4:27 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
This is a good post and with this “worldwide web” it will reach all corners of earth in seconds, technological advancements are making this world a much smaller place :-) Indian escorts
Left by London Escorts on Jun 05, 2011 12:09 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
We are a group of independents opening a new scheme in our community, you have done a good job here giving us a whole new way of looking at certain issues, great topic ice machine
Left by Newhand on Jun 16, 2011 9:45 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
Your article is very useful to me. With relevant evidence you provide the more makes me confident.
Left by tax accounting on Jun 23, 2011 7:00 AM

# re: Generic WCF Error Handler for ESB Guidance
Requesting Gravatar...
I like your comment I like too thank you too much.
Left by Cyber Monday 2012 on Oct 28, 2012 8:38 AM

Your comment:
 (will show your gravatar)


Copyright © Elton Stoneman | Powered by: GeeksWithBlogs.net