title: Basic HTTP authentication using KSOAP for android
body: <p>I need to consume a SOAP web service using Android.</p>
  
  <p>The issue is that before request for a particular function I need to authenticate a client using basic http request.</p>
  
  <p>Do you know how to do this using KSOAP?</p>
  
  <p>Until this moment I have tried using overloaded method of httpsTransportSE.call() as it suggest that I can specify additional headers for http connection </p>
  
  <blockquote>
    <p>(ref:
    <a href="https://github.com/mosabua/ksoap2-android/blob/master/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpTransportSE.java" rel="noreferrer">https://github.com/mosabua/ksoap2-android/blob/master/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpTransportSE.java</a>)</p>
  </blockquote>
  
  <pre><code>headerPropertyList.add(new HeaderProperty("Authorization", "Basic : dXNlcjpwYXNz"));
  </code></pre>
  
  <p>"cdXNlcjpwYXNz" is base 64 encoded string of "user:pass"</p>
  
  <pre><code> public List call(String soapAction, SoapEnvelope envelope, List headers)
      * @param headers a list of HeaderProperties to be http header properties when establishing the connection
  
  
  
  private static final String SOAP_ACTION = "someaddress/IPortReporting/GetPortStatus";
  private static final String METHOD_NAME = "methodname";
  private static final String NAMESPACE = "http://ssn.someaddress/2.0/";
  private static final String URL = "new.someaddress/functionName.svc";
  
  
  
  
  SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
          Request.addProperty("MessageId", "1");
  
          SoapSerializationEnvelope soapEnvelop = new SoapSerializationEnvelope(
                  11);
          //soapEnvelop.headerOut = addHeaders(); 
          soapEnvelop.dotNet = true;
          soapEnvelop.setOutputSoapObject(Request);
  
  
          List&lt;HeaderProperty&gt; headerPropertieList = new ArrayList&lt;HeaderProperty&gt;();
          headerPropertyList.add(new HeaderProperty("Authorization", "Basic : cG9ydHdzOjEyM3F3ZUFTRA=="));
          //HeaderProperty headerProperty = new HeaderProperty()
  
          HttpsTransportSE httpsse = new HttpsTransportSE(URL, 443, "", 5000);
  
  
  
          try {
              httpsse.call(SOAP_ACTION, soapEnvelop, headerPropertyList);
              //httpsse.call(SOAP_ACTION, soapEnvelop);
  
              SoapPrimitive resultString = (SoapPrimitive) soapEnvelop
                      .getResponse();
              tv.setText("Status: ");
          } catch (Exception e) {
              tv.setText("Some error," + " "
                      + e.getMessage());
          }
  </code></pre>
  
  <p>But I have message "permission denied" reported back.</p>