Webservice Http Authentication - KSOAP2 on Android

╄→гoц情女王★ 提交于 2019-11-28 04:54:04

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/5501743/webservice-http-authentication-ksoap2-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!