我已经在网上搜索了一段时间,但无法为我的问题找到合适的解决方案.这篇文章也没有真正的帮助,因为使用的类和方法在 ksoap2 for android 中不存在:使用 KSOAP for android 的基本 HTTP 身份验证
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
我正在尝试访问我在 sap soa 管理器中设置的 SAP web 服务.Web 服务需要在 http 标头中进行基本身份验证.通过soapUI访问这个web服务是没有问题的,因为可以在那里设置http认证.
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.
我的问题:我想使用 android 设备访问 Web 服务,并且我想使用 KSOAP2 for Android,因为我已经有一些使用该库的经验.我的问题是我不知道如何对 Web 服务进行身份验证?
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!
希望还不算太晚.这就是我使用 KSOAP 访问 SAP Web 服务的方式:
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);
将 XXXXXXXX 替换为您的用户名和密码的编码哈希.要获得它,只需查看soapUI 原始标头请求.希望能帮助到你.
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.
这篇关于Web 服务 Http 身份验证 - Android 上的 KSOAP2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!