title: Authenticating Soap with "Global Http Settings"
body: <p>I have to connect to a SOAP service from C#.NET, but the service only accepts requests with http authentication headers.  </p>
  
  <p>It seems (based on my googleing so far) like authentication via Http headers is not standard for SOAP, but I cannot make any changes to the SOAP service.</p>
  
  <p>Note: I am not talking about SOAP headers.</p>
  
  <p>I can set up the http authentication and make successful requests with SoapUI as shown:</p>
  
  <p><img src="https://i.stack.imgur.com/GNVWd.png" alt="Working SoapUI request, using &quot;Username&quot; and &quot;Password&quot; in the Authorisation tab"></p>
  
  <p>I may be wrong about what SoapUI is doing behind the scenes - this is http authentication right?</p>
  
  <p>I have imported the WSDL to my Visual Studio project, and can attempt to make requests but I get a "401 - Unauthorised (The HTTP request is unauthorized with client authentication scheme 'Anonymous'. )" error of course.</p>
  
  <p>I'd like to invoke the service in a way something like this:</p>
  
  <pre><code>    public List&lt;string&gt; GetVinsForUser(string customerId)
      {
          var client = new CustomerService.VehicleClient();
  
          // client.HttpHeaders.Add("username", "SomeUser");
          // client.HttpHeaders.Add("password", "SomePassword");
  
          var result = client.findCustomerPlusVehicles(customerId);
  
          return result.Vehicles.ToList();
      }
  </code></pre>
  
  <p>All the related articles I've seen so far seem to imply there is no easy property like this for the .NET implementation of SOAP.  </p>
  
  <p>I understand I could POST soap xml data to the endpoint building the entire webrequest by hand, but I really really don't want to hack this!</p>
  
  <p>Are there any ways to enable this kind of authentication, even by extending / overriding the behaviour of the generated Client class?</p>