Need to authenticate by login & password for soap webservice to sign in android app

1,429 views
Skip to first unread message

girish arora

unread,
Feb 28, 2014, 1:34:27 AM2/28/14
to ksoap2-...@googlegroups.com
Hi,

i need to login to access soap webservice to sign in in android app. I already sign in without authentication on web service, but i dont know how to do this. I googled a lot. Please help me

Alex N

unread,
Feb 28, 2014, 2:21:49 AM2/28/14
to ksoap2-...@googlegroups.com

Am Freitag, 28. Februar 2014 07:34:27 UTC+1 schrieb girish arora:
Hi,

i need to login to access soap webservice to sign in in android app. I already sign in without authentication on web service, but i dont know how to do this. I googled a lot. Please help me

Hi,

make a List with HeaderProperties and add them in the call parameters.


HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
try {
List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
headerList.add(new HeaderProperty("Authorization", "Basic " + org.kobjects.base64.Base64.encode((username + ":" + password).getBytes())));
androidHttpTransport.call(SOAP_ACTION, envelope, headerList);
result = (SoapObject)envelope.bodyIn; // or envelope.getResponse();
} catch (Exception ex)
{}


Kind Regards
Alex

girish arora

unread,
Feb 28, 2014, 3:12:23 AM2/28/14
to ksoap2-...@googlegroups.com
Thanx Alex,

i am new to soap, will u let me know how to handle string in soap as we can in json by json array & json object

Alex N

unread,
Feb 28, 2014, 4:19:09 AM2/28/14
to ksoap2-...@googlegroups.com
Sorry I can not help unfortunately with JSON. I use it with Android Java.

girish arora

unread,
Feb 28, 2014, 4:25:59 AM2/28/14
to ksoap2-...@googlegroups.com
Actually json is also used as web service in Android. I already worked in json how to send & retrive data. I want to know how can i differentitate data from SOAP web service, means if i am retrivng 10 values then how can i save those 10 values to 10 variables..?
Message has been deleted

Alex N

unread,
Feb 28, 2014, 7:15:32 AM2/28/14
to ksoap2-...@googlegroups.com


Am Freitag, 28. Februar 2014 10:25:59 UTC+1 schrieb girish arora:
Actually json is also used as web service in Android. I already worked in json how to send & retrive data. I want to know how can i differentitate data from SOAP web service, means if i am retrivng 10 values then how can i save those 10 values to 10 variables..?

You need to know, which structure your webservice response delivers.

for example:
<XML ..>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<n0:Response ...>
<test1>
<var1>value1</var1>
<var2>value2</var2>
<var3>value3</var3>
</test1>
<test2>
<var4>value4</var4>
<var5>value5</var4>
</test2>
</n0:Response>
   </soap-env:Body>
</soap-env:Envelope>

SoapObject object1 = (SoapObject)response.getProperty("test1");

==> This Object contains the test1-part of the xml tree. For the var1...3 you must use

String value = object1.getPropertyAsString("var1");

If there no value for the varible you get the String "anyType{}".
For debug you can use response.toString() -> complete object with all key/value-pairs.

See the javadocs for other methods ;)

I hope this answers your question ;)
 

girish arora

unread,
Feb 28, 2014, 7:21:23 AM2/28/14
to ksoap2-...@googlegroups.com

Actually since last 8 hours i am trying to do the same but cant. I am not able to authenticate. Please help me how can i send username & password via soap or soap header to authenticate valid soap user & can access that web service

Alex N

unread,
Feb 28, 2014, 7:26:19 AM2/28/14
to ksoap2-...@googlegroups.com


Am Freitag, 28. Februar 2014 13:21:23 UTC+1 schrieb girish arora:

Actually since last 8 hours i am trying to do the same but cant. I am not able to authenticate. Please help me how can i send username & password via soap or soap header to authenticate valid soap user & can access that web service

I think you should post your code.
Reply all
Reply to author
Forward
0 new messages