1

I have been trying to connect a web service that requires credentials to be accessed and have had no luck. I am using ksoap2 and I know the code works(I have used it with the local host before I put the web service on the server) I also know the server is working just fine because I made a c# program that accesses the server just fine. If someone could show me how to pass a username and password I would be very grateful.

EDIT: My issue has been fixed I am placing the code I used to fix it below.

        List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
    headers.add(new HeaderProperty("Authorization", "Basic "+Base64.encode("Username:Password".getBytes())));

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

/

 androidHttpTransport.call(SOAP_ACTION, envelope,headers);
error_null_pointer
  • 457
  • 1
  • 6
  • 21
  • Perhaps this similar question might be of some help to you: http://stackoverflow.com/questions/5501743/webservice-http-authentication-ksoap2-on-android – Lasse Samson Dec 08 '11 at 22:46
  • How did you configure the service to take username and password? – Shathur Dec 15 '11 at 15:28
  • The service was not what need the credentials in my case. Where I work the server needs authentication before you can even connect to it. the way above stored the user name and pass in the XML header. Parth_90 had and example of what you seem to want. Let me know if you need anything else – error_null_pointer Dec 15 '11 at 19:46

3 Answers3

0

1.ksoap2 has two version to accesss web service. SoapEnvelope.VER10 & SoapEnvelope.VER11 & SoapEnvelope.VER12, Please check it;

2.And do you add permission into AndroidManifast.xml?

<uses-permission android:name="android.permission.INTERNET" />

3.The WebService is base on HTTP or HTTPS? In your code they are HttpTransportSE or HttpsServiceConnectionSE.

4.If your emulator is connect to internet,please check the "3G" symbol.

5.At last,that also mess with the version of ksoap2.jar.

YETI
  • 928
  • 3
  • 12
  • 24
0

I have done a similar thing before. I created an Android application that accesses a web service for user authentication using ksoap.

You can refer How to call a local web service from Android Mobile App

Check the answer I have posted over there. That is exactly what your looking for. I am basically passing the user credentials to my webservice for authentication.

Hope it helps

Cheers

Community
  • 1
  • 1
Parth Doshi
  • 4,200
  • 15
  • 79
  • 129
  • On you application you connect to the service to authenticate you have a function that you pass in parameters, on mine however the server requires a user name and password to reach the server before I am able to access the web service. – error_null_pointer Dec 12 '11 at 21:13
0

If you only want to send the username and password then check the Parth_90 answer.

But if you want to use HTTPS then I think this would help: https://groups.google.com/forum/#!topic/android-developers/GsK4UeByabo (check the first answer).

Marcos
  • 4,643
  • 7
  • 33
  • 60
  • I already have a certificate in place I am unable to pass a username and password to the server though. In the link you sent me they get the error "javax.net.ssl.SSLException: Not trusted server certificate" I get no errors when I compile the problem comes in when I reach the server. The server replies with a some XML that says you are not allowed to view this page. I am sorry I should of been more clear about the error I was receiving. – error_null_pointer Dec 12 '11 at 21:19