当前位置:编程学习 > JAVA >>

android通过SOAP调用webservice出错,求解啊!急急急

LoaCat的信息:
05-15 17:24:40.149: I/HttpConnSoap(5309): ---------Step1---------
05-15 17:24:40.619: I/HttpConnSoap(5309): ---------Step2---------
05-15 17:24:40.699: I/HttpConnSoap(5309): ---------Step3---------
05-15 17:24:42.161: D/dalvikvm(5309): GC_CONCURRENT freed 237K, 13% free 2603K/2988K, paused 9ms+125ms, total 561ms
05-15 17:24:43.198: W/System.err(5309): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2001/12/soap-envelope}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/soap/envelope/}soap:Envelope>@1:208 in java.io.InputStreamReader@40cdefb8) 
05-15 17:24:43.259: W/System.err(5309):  at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
05-15 17:24:43.269: W/System.err(5309):  at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
05-15 17:24:43.269: W/System.err(5309):  at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
05-15 17:24:43.279: W/System.err(5309):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
05-15 17:24:43.279: W/System.err(5309):  at com.example.self.HttpConnSoap.GetWebServre(HttpConnSoap.java:32)
05-15 17:24:43.279: W/System.err(5309):  at com.example.self.resultt.getAllInfo(resultt.java:40)
05-15 17:24:43.279: W/System.err(5309):  at com.example.self.resultt.onCreate(resultt.java:32)
05-15 17:24:43.328: W/System.err(5309):  at android.app.Activity.performCreate(Activity.java:5104)
05-15 17:24:43.328: W/System.err(5309):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-15 17:24:43.379: W/System.err(5309):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-15 17:24:43.379: W/System.err(5309):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-15 17:24:43.409: W/System.err(5309):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-15 17:24:43.419: W/System.err(5309):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-15 17:24:43.419: W/System.err(5309):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 17:24:43.439: W/System.err(5309):  at android.os.Looper.loop(Looper.java:137)
05-15 17:24:43.439: W/System.err(5309):  at android.app.ActivityThread.main(ActivityThread.java:5041)
05-15 17:24:43.479: W/System.err(5309):  at java.lang.reflect.Method.invokeNative(Native Method)
05-15 17:24:43.479: W/System.err(5309):  at java.lang.reflect.Method.invoke(Method.java:511)
05-15 17:24:43.489: W/System.err(5309):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-15 17:24:43.489: W/System.err(5309):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-15 17:24:43.509: W/System.err(5309):  at dalvik.system.NativeStart.main(Native Method)
05-15 17:24:43.509: E/HttpConnSoap(5309): ---error---org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2001/12/soap-envelope}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/soap/envelope/}soap:Envelope>@1:208 in java.io.InputStreamReader@40cdefb8) 
05-15 17:24:43.509: D/AndroidRuntime(5309): Shutting down VM
05-15 17:24:43.529: W/dalvikvm(5309): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
05-15 17:24:43.598: E/AndroidRuntime(5309): FATAL EXCEPTION: main
05-15 17:24:43.598: E/AndroidRuntime(5309): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.self/com.example.self.resultt}: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.os.Looper.loop(Looper.java:137)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.app.ActivityThread.main(ActivityThread.java:5041)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at java.lang.reflect.Method.invokeNative(Native Method)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at java.lang.reflect.Method.invoke(Method.java:511)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at dalvik.system.NativeStart.main(Native Method)
05-15 17:24:43.598: E/AndroidRuntime(5309): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0
05-15 17:24:43.598: E/AndroidRuntime(5309):  at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at java.util.ArrayList.get(ArrayList.java:304)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at com.example.self.resultt.getAllInfo(resultt.java:41)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at com.example.self.resultt.onCreate(resultt.java:32)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.app.Activity.performCreate(Activity.java:5104)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-15 17:24:43.598: E/AndroidRuntime(5309):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-15 17:24:43.598: E/AndroidRuntime(5309):  ... 11 more


访问webservicejava代码:
package com.example.self;

import java.util.ArrayList;
import java.util.List;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;

public class HttpConnSoap {
private final static String TAG = "HttpConnSoap";
 private  List<String> provinces ;
 public List<String> GetWebServre(String methodName) {  
     String ServerUrl = "http://10.0.2.2:58288/Service1.asmx"; 
     String NameSpace="http://tempuri.org/";
     String soapAction = "NameSpace+methodName;
     SoapObject request = new SoapObject(NameSpace, methodName); 
     Log.i(TAG, "---------Step1---------");
     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
     Log.i(TAG, "---------Step2---------");
     envelope.dotNet=true;
     envelope.bodyOut=request;
     envelope.setOutputSoapObject(request);
     provinces = new ArrayList<String>();         
     HttpTransportSE androidHttpTransport = new HttpTransportSE(ServerUrl);
     androidHttpTransport.debug=true;
     Log.i(TAG, "---------Step3---------");
     try{ 
     androidHttpTransport.call(soapAction, envelope );
       Log.i(TAG, "---------Step4---------");
     if (envelope.getResponse() != null){
      Log.e(TAG, "访问到web");
     SoapObject result=(SoapObject)envelope.getResponse(); 
     int count=result.getPropertyCount(); 
        for ( int  index=0;index<count;index++){
         provinces.add(result.getProperty(index).toString()); }
        }
       Log.i(TAG, "---------Step5---------");
     }catch (Exception e) {
         e.printStackTrace();
         Log.e(TAG, "---error---"+e.toString());
        
     }
     return provinces;
    
     }
   }  

到底是什么原因啊,感觉代码没错啊
   


--------------------编程问答-------------------- Caused by: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0
越界了。大小是0,你使用了1.

com.example.self.resultt这个东西在哪里,ComponentInfo这个activity --------------------编程问答-------------------- SoapObject result=(SoapObject)envelope.getResponse(); 这里调回的是空值,不知道什么原因啊
com.example.self.resultt这是一个activity --------------------编程问答-------------------- 已经解决了,呵呵 --------------------编程问答--------------------
引用 3 楼 zengshengnan 的回复:
已经解决了,呵呵
请问怎么解决的 ?我今天刚接触 实在不知道如何解决 --------------------编程问答-------------------- 解决了也不告诉方法,唉~
补充:Java ,  Eclipse
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,