title: Sending userID to WCF service without sending as method parameter
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1976217/how-to-add-custom-soap-headers-in-wcf">How to add custom soap headers in wcf?</a>  </p>
  </blockquote>
  
  
  
  <p>Here's the scenario:</p>
  
  <p>I have a WCF service which we'll call "BusinessService."</p>
  
  <p>I also have a web app which has a client of this service to send requests.</p>
  
  <p>I want to be able to log who is sending an update to my service; because of this, my BusinessService has a private string member called _userID as well as a method to set this _userID, this class looks like this:</p>
  
  <pre><code>public class BusinessService : IBusinessService
  {
      private string _userID;
  
      public void SetUserID(string userID)
      {
          _userID = userID;
      }
  
      public void UpdateCustomer(Customer customer)
      {
          // update customer here.
      }
  }
  </code></pre>
  
  <p>Because of the way the above class is written (since it isn't easy to have a custom custructor for WCF services in which I can just pass the userID,) then my web app is written like so:</p>
  
  <pre><code>public class WebApp
  {
      private string _userID; // on page load this gets populated with user's id
  
      // other methods and properties
  
      public void btnUpdateCustomer_Click(object sender, EventArgs e)
      {
          Customer cust = new Customer();
  
          // fill cust with all the data.
  
          BusinessServiceClient svc = InstantiateWCFService();
          svc.UpdateCustomer(cust);
          svc.Close();
      }
  
      private BusinessServiceClient InstantiateWCFService()
      {
          BusinessServiceClient client = new BusinessServiceClient("EndPointName");
          client.SetUserID(_userID);
          return client;
      }
  }
  </code></pre>
  
  <p>When looking at the data stored, nothing is saved for the user id.</p>
  
  <p>Is there some form of design pattern, or feature that allows me to log who is making some change without having my service require the userID in <strong>every</strong> method call?</p>