Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6374099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:26:46+00:00 2026-05-25T01:26:46+00:00

I have a problem when access to WSDL resource with basic authentication from android.

  • 0

I have a problem when access to WSDL resource with basic authentication from android.

Code:

package ru.itgorod.test.wsdl;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.ksoap2.HeaderProperty;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class WSDLTestActivity extends Activity {

    private static final String NAMESPACE = "http://www.example.ru/lecompre";
    private static final String URL="http://10.0.0.233/lecompre/ws/lecompre?wsdl"; 
    private static final String METHOD_NAME = "GetGoodsList";
    private static final String SOAP_ACTION =  "http://www.example.ru/lecompre/GetGoodsList";   

    private static final String USERNAME = "WS";
    private static final String PASSWORD = "";

    private TextView txt;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        txt = (TextView) findViewById(R.id.textView1);

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        Log.i("wsdl", "1");

        androidHttpTransport.debug = true;

        StringBuffer auth = new StringBuffer(USERNAME);
        auth.append(':').append(PASSWORD);
        byte[] raw = auth.toString().getBytes();
        auth.setLength(0);
        auth.append("Basic ");
        org.kobjects.base64.Base64.encode(raw, 0, raw.length, auth);
        List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
        headers.add(new HeaderProperty("Authorization", auth.toString())); // "Basic V1M6"));

        try {
            Log.i("wsdl", "2");
            Object response = androidHttpTransport.call(SOAP_ACTION, envelope, headers); // I got an XmlPullParserException here
            Log.i("wsdl", "3");
        } catch (IOException e) {
            txt.setText("IOException");
        } catch (XmlPullParserException e) {
            txt.setText("XmlPullParserException");
        }

        SoapObject result = null;
        try {
            Log.i("wsdl", "4"); 
            result = (SoapObject)envelope.getResponse(); 
            Log.i("wsdl", result.toString());
        } catch (SoapFault e) {
            txt.setText("SoapFault");
        }                    
    }
}

On androidHTTPTransport.call() I got an exception. Server returns an answer “Access is denied”. But as I can see in debug androidHTTPTransport.connection.connection.reqHeader.props “autorization” header is already here: [user-agent, kSOAP/2.0, content-type, text/xml, connection, close, content-length, 330, authorization, Basic V1M6]
But in resHeader I got “HTTP/1.1 401 Authorization Required”.

When I trying to open URL in browser – it works fine, but it use GET method with the same “Authorization: Basic V1M6” header.

Can anybody explain where I’m wrong in my code?

Thank you in advance!

UPDATE. I found why it happend. ksoap2 transport gives (via HttpURLConnection class) to server http headers in small letters, but server (sometimes) expect each of it with capital initial letter. And I can’t understand (can’t find in source codes) why and where HttpURLConnection makes it small.

UPDATE 2. After my investigation I can assert that this problem concern to core Android libs on version 2.2 (and, may be, older) but not to ksoap2-android itself.
Android 2.3 have no this issue – it send headers in needed case, and also have Authenticator class worked (see HTTP Authentication section of HttpURLConnection at Android Developers) which prevent from using workaround methods like used in the code above for authentication.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:26:46+00:00Added an answer on May 25, 2026 at 1:26 am

    After my investigation I can assert that this problem concern to core Android libs of version 2.2 (and, may be, older) but not to ksoap2-android itself. Android 2.3 have no this issue – it send headers in needed case, and also have Authenticator class worked (see HTTP Authentication section of HttpURLConnection at Android Developers) which prevent from using workaround methods like used in the code above for authentication.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem creating new instance of excel 2007 using VBA (from Access 2002).
Problem: I have an address field from an Access database which has been converted
I have some problem to access the Window's DataContext from within a DataGrid. The
I have a problem when I try to access to a webservice from a
i have a problem here of displaying a date type from ms access db
i have this problem: ms-access could not delete and i found a potential solution
i have a problem with a exc bad access. I already turned in NSZombieEnabled,
I have a problem where I always need to give simple access to my
I have a problem getting boost::multi_index_container work with random-access and with orderd_unique at the
We have a website made by Django. And there is no problem when access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.