Web 服务 Http 身份验证 - Android 上的 KSOAP2

Webservice Http Authentication - KSOAP2 on Android(Web 服务 Http 身份验证 - Android 上的 KSOAP2)
本文介绍了Web 服务 Http 身份验证 - Android 上的 KSOAP2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网上搜索了一段时间,但无法为我的问题找到合适的解决方案.这篇文章也没有真正的帮助,因为使用的类和方法在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)