title: Authorization: Basic in client for SOAP Service
body: <p>The application SoapUI I set a password and user name for the endpoint. When you call the method, these data are not transmitted in the message header but outside of it (<code>Authorization: Basic YTph</code>). However, in this case the call is successfully authenticated. If I try to add the authentication data in the header in my c# client application, the service does not see user names. </p>
  
  <p>SoapUI:</p>
  
  <pre><code>POST https://xxx.xx:9444/xx HTTP/1.1
  Accept-Encoding: gzip,deflate
  Content-Type: text/xml;charset=UTF-8
  SOAPAction: ""
  Authorization: Basic YTph
  Content-Length: 470
  Host: xx.loc:9444
  Connection: Keep-Alive
  User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
  
  &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ami="http://xxx.pl"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;ami:getMeterPointStates&gt;
        &lt;addr&gt;
            &lt;ppec&gt;0&lt;/ppec&gt;
            &lt;mid&gt;0&lt;/mid&gt;
          &lt;/addr&gt;
          &lt;start&gt;2012-04-01T00:00:00&lt;/start&gt;
          &lt;stop&gt;2012-05-01T00:00:00&lt;/stop&gt;
          &lt;hard&gt;false&lt;/hard&gt;
        &lt;/ami:getMeterPointStates&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>C# Client samle code:</p>
  
  <pre><code>System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(RemoteCertValidate);
  CommunicationWebserviceClient client = new CommunicationWebserviceClient();
  
  client.ClientCredentials.UserName.UserName = "user";
  client.ClientCredentials.UserName.Password = "password";
  
  using (new System.ServiceModel.OperationContextScope(client.InnerChannel))
  {
      MessageHeader head = MessageHeader.CreateHeader("Authorization", "http://xxx.pl", "Basic YTph");
      OperationContext.Current.OutgoingMessageHeaders.Add(head);
  
      MeterPointAddr addr = new MeterPointAddr();
      addr.ppec = "0";
      addr.mid = "0";
  
      var response = client.getMeterPointStates(addr, new DateTime(2012, 4, 1), new DateTime(2012, 4, 14), false, "", measurementsFlagEnum.REAL_ESTIMATION);
  }
  </code></pre>
  
  <p>App.config:</p>
  
  <pre><code> &lt;bindings&gt;
      &lt;customBinding&gt;
          &lt;binding name="CommunicationWebservicePortBinding"&gt;
              &lt;textMessageEncoding messageVersion="Soap11" /&gt;
  
              &lt;httpsTransport authenticationScheme="Basic" /&gt;
          &lt;/binding&gt;
      &lt;/customBinding&gt;
  &lt;/bindings&gt;
  &lt;client&gt;
      &lt;endpoint address="https://xxx.xx:9444/xx"
          binding="customBinding" bindingConfiguration="CommunicationWebservicePortBinding" contract="AMIService.CommunicationWebservice"
          name="CommunicationWebservicePort" /&gt;
  &lt;/client&gt;
  </code></pre>
  
  <p>How do I add a client written in c # that (<code>Authorization: Basic YTph</code>) header?</p>