title: WCF service queries
body: <p>I have a WCF service and methods are exposed as below:</p>
  
  <pre><code>public interface IService
  {
     [OperationContract]
     bool Read();
     [OperationContract]
     bool Write();
  }
  
  public class MyService : IService
  {
  
      //Constructor
  
      MyService()
      {
          //Initialization
      }
  
      public bool Read()
      {
          //Definition
      }
  
      public bool Write()
      {
          //Definition
      }
  }
  </code></pre>
  
  <p>I have a desktop based application that consumes the Web service through URL.
  This web service can be deployed at multiple location so user can connect to any web service by choosing a url from the combo box.</p>
  
  <p>In the client application I create a Service client dynamically as shown below:</p>
  
  <pre><code>ServiceReference1.DXMyServiceClient _client = null;
  
  _client = new DXMyServiceClient ();
  
  _client.Endpoint.Address = new System.ServiceModel.EndpointAddress(url);
  </code></pre>
  
  <p><strong>Questions</strong>
  While debugging I notice whenever I call any methods of web service each time the constructor of MyService  is invoked ( if I am connected to the same service).</p>
  
  <p>like for example when I do:</p>
  
  <pre><code>_client.Read();//MyService () constructor is called 
  
  _client.Write();//MyService () constructor is called 
  </code></pre>
  
  <p>The problem is I have to do all the initialization again.. like if I connecting to the database then I have to again build the connection string and all stuff..</p>
  
  <p>Is this the natural behavior or I am doing something wrong?</p>
  
  <p>Secondly,
  I want to validate user for the valid url ( of web service ). If it is connecting to the valid url or not.. I am doing that through Ping command..
  What is the best approach for that!!</p>