title: How to set Password Type in C# while consuming a SOAP web service
body: <p>I am trying to consume a third-party SOAP web service in my C# console app. I tried two different way of passing the credentials as shown below.</p>
  
  <pre><code>//Method 1 - passing security credentials
  myCardService.Credentials = new System.Net.NetworkCredential("username", 
  "password");
  
  //Method 2 - passing security credentials
  System.Net.CredentialCache myCredentials = new System.Net.CredentialCache();
  NetworkCredential netCred = new NetworkCredential("username", "password");
  myCredentials.Add(new Uri(myCardService.Url), "Basic", netCred);
  myCardService.Credentials = myCredentials;
  </code></pre>
  
  <p>In both the cases, I am getting this exception:  </p>
  
  <blockquote>
    <p>System.Web.Services.Protocols.SoapHeaderExceptions: Error in SecurityHeader: An Invalid security token was provided</p>
  </blockquote>
  
  <p>When I tried SOAP UI to consume the service, there also I got the same error. However, when I made WSS-Password Type = PasswordText in the Properties window of the tool, then it worked. I don't see any way to make this setting in the credential objects in the C# code. Any help is greatly appreciated.</p>