Category Archives: android-ksoap2

KSoap2 with htaccess and https

I'm using KSoap2 and I got an issue while trying to connect to a WSDL located on a server using HTTPS and protected by a htaccess.

Here is the error I got :

SoapFault - faultcode: 'WSDL' faultstring: 'SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://login:[email protected]://' : failed to load external entity "http://login:[email protected]://"

As you can see, the URL is weird.

Here is my code :

private Object send(SoapObject request)
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = false;
    envelope.xsd = SoapSerializationEnvelope.XSD;
    envelope.enc = SoapSerializationEnvelope.ENC;

    URI url = null;
    try {
        url = new URI(sUrl); //sUrl is ""
    } catch (URISyntaxException e) {
        return null;

    HttpsTransportSE ht = new HttpsTransportSE(url.getHost(), 443, url.getPath(), 30000);

    List<HeaderProperty> headerProperties = new ArrayList<>();
    HeaderProperty prop;
    auth = "Basic " + Base64.encodeToString((sHtaccessLogin+":"+sHtaccessPassword).getBytes(), Base64.NO_WRAP);
    try {
        prop = new HeaderProperty("Authorization", auth);
        headerProperties.add(prop);, envelope, headerProperties);

    } catch (IOException | XmlPullParserException e) {

The code is working fine when there is no htaccess.

Any idea ?

Web service for android not working properly

I'm trying to invoke a web service through my android app, i just write in a text box a name, press a button and the web service should return to me "hello + name". But it isn't working, i went through a lot of errors but this is the latest one, and i can't find a way out.

This is the web service written in java (Eclipse),

public class CallerClass {
public String Calling(String name){
    return "Hello" + name;

Its a java class inside a dynamic web project to which i added a web service (and works on the server according to the tutorials)

On the other hand this is the android app part:

 b.setOnClickListener(new OnClickListener() {
	           public void onClick(View v) {
	               //Check if Name text control is not empty
	               if (et.getText().length() != 0 && et.getText().toString() != "") {
	                   //Get the text control value
	                   editText = et.getText().toString();
	                   //Create instance for AsyncCallWS
	                   AsyncCallWS task = new AsyncCallWS();
	                   //Call execute 
	               //If text control is empty
	               } else {
	                   tv.setText("Please enter name");

Now this is the internal asyncTask class:

private class AsyncCallWS extends AsyncTask<String, Void, Void> {
	    protected Void doInBackground(String... params) {
	                    //Invoke webservice
	        displayText = WebService.invokeHelloWorldWS(editText,"Calling");
	        return null;

	    protected void onPostExecute(Void result) {
	        //Set response
	                    //Make ProgressBar invisible

	    protected void onPreExecute() {
	                    //Make ProgressBar invisible

	    protected void onProgressUpdate(Void... values) {


Finally this is the class calling the web service from the app:

public class WebService {

	//Namespace of the Webservice - It is for .NET webservice
    private static String NAMESPACE = "";
    //Webservice URL - It is asmx file location hosted in the server in case of .Net
        //Change the IP address to your machine IP address    
    private static String URL = ""	;
    //SOAP Action URI again
    private static String SOAP_ACTION = "";
    public static String invokeHelloWorldWS(String name, String webMethName) {
        String resTxt = null;
        // Create request
        SoapObject request = new SoapObject(NAMESPACE, webMethName);
        // Property which holds input parameters
        PropertyInfo sayHelloPI = new PropertyInfo();
        // Set Name
        // Set Value
        // Set dataType
        // Add the property to request object
        // Create envelope
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
        //Set envelope as dotNet
        envelope.dotNet = true;
        // Set output SOAP object
        // Create HTTP call object
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {
            // Invoke web service
  , envelope);
            // Get the response
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            // Assign it to resTxt variable static variable    
           resTxt = response.toString();
        } catch (SoapFault fault) {
            Log.v("TAG", "soapfault = "+fault.getMessage());

        catch (Exception e) {
            //Print error
            //Assign error message to resTxt
            resTxt = e.toString();
        //Return resTxt to calling object
        return resTxt;

Error I am getting this error

java.lang.ArrayIndexOutOfBoundsException: 1
at org.apache.axis2.databinding.utils.BeanUtil.deserialize( 630)
at org.apache.axis2.rpc.receivers.RPCUtil.processRequest( 153)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass( 206)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic( 117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic( 40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive( 114)
at org.apache.axis2.engine.AxisEngine.receive( 181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest( 172)
at org.apache.axis2.transport.http.AxisServlet.doPost( 146)
at javax.servlet.http.HttpServlet.service( 644)
at javax.servlet.http.HttpServlet.service( 725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( 291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter( 206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter( 52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( 239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter( 206)
at org.apache.catalina.core.StandardWrapperValve.invoke( 219)
at org.apache.catalina.core.StandardContextValve.invoke( 106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke( 503)
at org.apache.catalina.core.StandardHostValve.invoke( 136)
at org.apache.catalina.valves.ErrorReportValve.invoke( 79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke( 610)
at org.apache.catalina.core.StandardEngineValve.invoke( 88)
at org.apache.catalina.connector.CoyoteAdapter.service( 526)
at org.apache.coyote.http11.AbstractHttp11Processor.process( 1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process( 655)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process( 222)
at$SocketProcessor.doRun( 1566)
at$ 1523)
at java.util.concurrent.ThreadPoolExecutor.runWorker( 1142)
at java.util.concurrent.ThreadPoolExecutor$ 617)
at org.apache.tomcat.util.threads.TaskThread$ 61)
at 745)

Please help i've been at this for 2 days, it's a simple web service, i tried modifying it to print a message on my console but still the same error. Where is the problem? Configuration for the web service? or what...