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 8206949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:50:51+00:00 2026-06-07T08:50:51+00:00

My application calls a web-service using WCF. The call can fail for various reasons:

  • 0

My application calls a web-service using WCF. The call can fail for various reasons:

  • fault
  • timeout
  • connection lost
  • …

I want to log all such errors. Instead of wrapping every call in a try-catch, I want to do this in one place for all web-service calls in the entire application.

Unfortunately, an IClientMessageInspector does not get called for timeouts and connection failures. Is there a WCF extensibility point that I can use to centrally take note of all exceptions?

Notice, that I do not just want to log errors as text like WCF Tracing does it. I want to log:

  • ServiceName
  • MethodName
  • Duration
  • Exception.ToString()

I am open to workarounds.

  • 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-06-07T08:50:52+00:00Added an answer on June 7, 2026 at 8:50 am

    I am not aware of an extensibility point, but I can provide a workaround that we have used. Basically, we created a “proxy” that all service calls were made through. Below is the proxy and an example of its use.

    /// <summary>
    /// Proxy for executing generic service methods
    /// </summary>
    public class ServiceProxy
    {
        /// <summary>
        /// Execute service method and get return value
        /// </summary>
        /// <typeparam name="C">Type of service</typeparam>
        /// <typeparam name="T">Type of return value</typeparam>
        /// <param name="action">Delegate for implementing the service method</param>
        /// <returns>Object of type T</returns>
        public static T Execute<C, T>(Func<C, T> action) where C : class, ICommunicationObject, new()
        {
            C svc = null;
    
            T result = default(T);
    
            try
            {
                svc = new C();
    
                result = action.Invoke(svc);
    
                svc.Close();
            }
            catch (FaultException ex)
            {
                // Logging goes here
                // Service Name: svc.GetType().Name
                // Method Name: action.Method.Name
                // Duration: You could note the time before/after the service call and calculate the difference
                // Exception: ex.Reason.ToString()
    
                if (svc != null)
                {
                    svc.Abort();
                }
    
                throw;
            }
            catch (Exception ex)
            {
                // Logging goes here
    
                if (svc != null)
                {
                    svc.Abort();
                }
    
                throw;
            }
    
            return result;
        }
    }
    

    And an example of its use:

    var result = ServiceProxy.Execute<MyServiceClient, MyReturnType>
    (
        svc => svc.GetSomething(someId)
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an application which involves so many web-service calls. I am using
I am using a WCF authentication service I set up with a web application.
I am creating a WCF web service using wsHttpBinding and a corresponding application that
I have develope a small web application in that i am using wcf service,I
Using JDeveloper as my IDE, I have a web application which calls services provided
I've the following issue I've a windows application It calls a remote web service
A C# client application we developed calls an external SOAP web service of a
I am trying to call a web service from asp.net 3.5 application. I have
We have a Java web service that we call from our application. When we
I'm developing a web service using NHibernate, WCF and Oracle 11g R1. The web

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.