Webservice的HTTP认证 - KSOAP2在Android [英] Webservice Http Authentication - KSOAP2 on Android
问题描述
我一直在网上搜索了一段时间了,但没能找到我的问题一个合适的解决方案。本文并没有真正帮助的,因为所使用的类和方法都没有present在ksoap2为Android:<一href="http://stackoverflow.com/questions/5177939/basic-http-authentication-using-ksoap-for-android">Basic使用KSOAP为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的web服务,这是我在SAP的SOA管理设置。该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为Android,因为我已经有一个libary一些经验。我的问题是,我不知道如何来验证到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!
推荐答案
我希望这不是为时已晚。这就是我如何访问SAP Web服务与KSOAP:
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);
替换为您的用户名和密码的连接codeD散列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.
这篇关于Webservice的HTTP认证 - KSOAP2在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!