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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:25:50+00:00 2026-05-28T07:25:50+00:00

I am developing a web application with multiple WCF service references. Currently, each time

  • 0

I am developing a web application with multiple WCF service references. Currently, each time we need to make a call to a service we do the following(as an example):

Service.ServiceClient ServiceClient = new Service.ServiceClient();
ServiceClient.SomeMethod();

Would it be better to have a static class with static references to each Service and call that class instead, thereby avoiding creating a new instance of the ServiceClient object each time we want to call it?

For example:

public static class Services
{
    private static Service.ServiceClient _ServiceClient = new Service.ServiceClient();
    public Service.ServiceClient ServiceClient
    {
        get
        {
            return _ServiceClient;
        }
    }
}

And, if doing it this way, would the line

private static Service.ServiceClient _ServiceClient = new Service.ServiceClient();

cause a new object to be created each time we try to call that object, or will it be the same instance of that object every time we make a call to it?

  • 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-28T07:25:50+00:00Added an answer on May 28, 2026 at 7:25 am

    You can have a class which will have all the functions exposed by your data contract. All these methods will be static. Now inside these function you can do as follows

    public class ServiceManager{
        public static CalculatedData SomeMethod()
        {
             var client = GetClient();
             try
             {
                 return client.SomeMethod();
             }
             catch(Exception ex)
             {
                 //Handle Error
             }
             finally
             {
                 if(client.State == System.ServiceModel.CommunicationState.Opened)
                    client.Close();
             } 
    
        }
        private static SomeClient GetClient()
        {
             return new ServiceClient();
        }
    } 
    

    Consumer will consume it like

    var calculatedData = ServiceManager.SomeMethod();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary: I'm developing a persistent Java web application, and I need to make sure
I am currently developing a web application which will be used by multiple clients,
I'm developing a web application and I need to mix Forms & Windows authentication
I'm currently developing a web application in ASP.Net with SQL Server and I would
I am developing a web application that collects data over multiple steps through a
I am developing a web application where I need to find the closest bus-stop
I am developing web application where users have collection of tags. I need to
I'm developing a java servlet web application that manages information from multiple databases (all
I am developing a new web application from scratch. I need to provide multi-language
I am developing an application with multiple windows, all using their own web services.

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.