开发者

Webservice Http Authentication - KSOAP2 on Android [duplicate]

开发者 https://www.devze.com 2023-02-20 20:54 出处:网络
This question already has answers here: Add CSS or JavaScript files to layout head from views or partial views
This question already has answers here: Add CSS or JavaScript files to layout head from views or partial views 开发者_StackOverflow中文版 (10 answers) Closed 2 years ago.

I have been searching the web for a while now, but wasn't able to find a appropriate solution for my problem. This article does not really help either, because the classes and methods used are not present in ksoap2 for android: Basic HTTP authentication using KSOAP for android

I am trying to access a SAP webservice, which I set up in the sap soa manager. The webservice requires basic authentication in the http header. Accessing this web service by soapUI is not a problem, because it is possible to set up http authentication there.

My Problem: I want to access the web service with a android device and I want to use KSOAP2 for Android because I already have some experience with that libary. My problem is that I don't know how to authenticate to the webservice?

Has anyone had a similar problem and knows how to solve it? I would be grateful if you could help me!


I hope it is not too late. That is how I access SAP webservice with KSOAP:

List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
headers.add(new HeaderProperty("Authorization", "Basic XXXXXXXXXX"));
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
Object result = null;               
final Object response = androidHttpTransport.call(SOAP_ACTION, envelope, headers);

Replace the XXXXXXXX with the encoded hash of your username and password. To get it just look in soapUI raw header request. Hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号