2012-01-25 83 views
0

我試圖通過ksoap認證到SAP服務器,我被卡住了......它似乎不想考慮我的用戶名和密碼。這是我的代碼:無法通過ksoap2認證

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
List<HeaderProperty> headers = new ArrayList<HeaderProperty>(); 
     String code = Base64.encode("usernametxt:pass".getBytes()); 
     headers.add(new HeaderProperty("Authorization", "Basic " + code)); 
     System.out.println("req dump: " + androidHttpTransport.requestDump); 
     MarshalBase64 marshal = new MarshalBase64(); 
     marshal.register(envelope); 
     androidHttpTransport.call(SOAP_ACTION, envelope, headers); 
String res = androidHttpTransport.responseDump; 

我得到這個錯誤:

expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@1:6 in [email protected]) 

[2012-01-25 12點25分14秒 - 模擬器] W/System.err的(503):org.xmlpull .v1.XmlPullParserException:expected:START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope(position:START_TAG @ 1:6 in [email protected]) [2012-01-25 12 :25:14 - Emulator] W/System.err(503):at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at org.kxml2.io.KXmlParser.require(KXmlParser.java:1424) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127) [2012-01-25 12:25: 14 - Emulator] W/System.err(503):at org.ksoap2.transport.Transport.parseResponse(Transport.java:100) [2012-01-25 12:25:14 - Emulator] W/System.err (503):at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at com.test。 TestWebserviceActivity.onCreate(TestWebserviceActivity.java:78) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) [2012-01-25 12:25:14 - 仿真器] W/System.err(503) :at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at android.app.ActivityThread.access $ 1500( ActivityThread.java:117) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:931) [2012 -01-25 12:25:14 - Emulator] W/System.err(503):at android.os.Handler.dispatchMessage(Handler.java:99) [2012-01-25 12:25:14 - Emulator ] W/System.err(503):at android.os.Looper.loop(Looper.java:123) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at android.app.ActivityThread.main(ActivityThread.java:3683) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at java.lang.reflect.Method.invokeNative(Native方法) [2012-01-25 12:25:14 - Emu (503):at java.lang.reflect.Method.invoke(Method.java:507) [2012-01-25 12:25:14 - Emulator] W/System.err(503) ):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at com。 android.internal.os.ZygoteInit.main(ZygoteInit.java:597) [2012-01-25 12:25:14 - Emulator] W/System.err(503):at dalvik.system.NativeStart.main(Native方法)

響應爲null,androidHttpTransport.requestDump爲null。 我做錯了什麼,你知道嗎? 謝謝

回答

0

這KSOAP jar文件的版本,你using.Use最新版本

+0

ksoap2-Android的組裝2.6.0-JAR-與依賴性 – user1140656

+0

我認爲這是它的最後一個版本。只是不知道什麼是錯的。 – user1140656