title: Pre authenticate web service request in C#
body: <p>I'm having a problem with calling a web service request in C#.</p>
  
  <p>The service and request are working fine in Soap UI with the option 'Authenticate Preemptively' enabled (File, Preferences, HTTP Settings). Without this setting enabled the service returns a 'Java.Lang.NullPointerException'.</p>
  
  <p>The problem I'm having is that I do not know how to enable this setting in a C# context.</p>
  
  <p>I have a .NET 3.5 class library which holds a so called service reference to the specific service. This is a simple code snippet;</p>
  
  <pre><code>try
  {
      CatalogService.CatalogChangeClient service = new CatalogService.CatalogChangeClient();
      service.ClientCredentials.UserName.UserName = "fancydress";
      service.ClientCredentials.UserName.Password = "47fda9cb4b51a9e";
      service.ClientCredentials.SupportInteractive = true;
  
      ProductUpdate[] products = new ProductUpdate[1];
      products[0] = new ProductUpdate();
      products[0].ProductCode = "00001";
      products[0].ProductDescription = "TestProduct";
  
      string result = service.UpdateProducts(products);
  }
  catch (Exception exception)
  {
      Console.WriteLine(exception.Message);
  }
  </code></pre>
  
  <p><strong>Update after first reply.</strong></p>
  
  <p>The CatalogService.CatalogChangeClient class seems to implement the WCF abstract class</p>
  
  <pre><code>System.ServiceModel.ClientBase&lt;TChannel&gt;
  </code></pre>
  
  <p><strong>End Update</strong></p>
  
  <p>Could anyone help me set this property?</p>