title: .net core 2 and Higher : connected services WcfServiceClient SOAP with NTLM Authorization how to?
body: <p>I'm running an application on .net core 2.1.
  I added a wsdl web service through connected services that generated me a WcfServiceClient successfully.</p>
  
  <p>When using <strong>Basic Autorization</strong> it works <strong>fine</strong>.</p>
  
  <p>here is the class I use for calling a helloword soap method : </p>
  
  <pre><code>public string HellowWorld(string input)
  {
      string wsRes = null;
      try
      {
          var service = new WorkerProcessServiceClient();
          var url = $"http://ServerUrl/Directory/WsName.svc";
          UriBuilder uriBuilder = new UriBuilder(url);
  
          service.Endpoint.Address = new EndpointAddress(uriBuilder.Uri);
          service.ClientCredentials.UserName.UserName = Username;
          service.ClientCredentials.UserName.Password = Password;
  
          using (OperationContextScope scope = new OperationContextScope(service.InnerChannel))
          {
              HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
              httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] =
                  "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(service.ClientCredentials.UserName.UserName
                  + ":"
                  + service.ClientCredentials.UserName.Password));
              OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
              wsRes = service.HelloWorldAsync(input, RetailContext).GetAwaiter().GetResult();
              service.Close();
          }
      }
      catch (Exception ex)
      {
          wsRes = ex.Message;
      }
      return wsRes;
  }
  </code></pre>
  
  <p>This is working fine with servers that are running on <strong>Basic Authorization</strong>. I am using the same credentials with <strong>SOAP UI</strong> and it is working very well. and I dont even need to specify the 
  <a href="https://i.stack.imgur.com/Bgdkx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bgdkx.png" alt="enter image description here"></a></p>
  
  <p>&lt;==> Now The Problem &lt;=></p>
  
  <p>I have a second server that runs with <strong>NTLM Authorization</strong>.
  I done it all :'( but nothing seems working.</p>
  
  <p>1 - I changed my <code>service.clientCredential.Username</code> to <code>service.clientCredential.Windows</code> and I added <code>service.clientCredential.Windows.domain</code></p>
  
  <p>2 - I changed the Header also from <code>"Basic " + Convert...</code> to <code>"Ntlm " + Convert...</code></p>
  
  <p>3 - I added the domain in the header and I put it first and last position. </p>
  
  <p>when I use <strong>SOAP UI</strong>,  it is working just fine.
  <a href="https://i.stack.imgur.com/enySv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/enySv.png" alt="enter image description here"></a></p>
  
  <p>I dont know what to do else Please Help.</p>