在Android中解析SOAP Webservice时出现此错误

时间:2013-04-14 16:42:17

标签: android soap ksoap

04-14 22:09:40.158: E/REQUEST=(274): Authenticate{Username=lll; }
04-14 22:09:40.158: E/SOAP ENVOLP=(274): **envolpe=org.ksoap2.serialization.SoapSerializationEnvelope@43e5b748
04-14 22:09:43.799: W/System.err(274): org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT 
04-14 22:09:43.799: W/System.err(274): Warning: DOMXPa...@27:1 in java.io.InputStreamReader@43e6ec48)** 
04-14 22:09:43.819: W/System.err(274):  at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
04-14 22:09:43.819: W/System.err(274):  at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1420)
04-14 22:09:43.819: W/System.err(274):  at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)
04-14 22:09:43.819: W/System.err(274):  at org.ksoap2.transport.Transport.parseResponse(Transport.java:90)
04-14 22:09:43.819: W/System.err(274):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:179)
04-14 22:09:43.819: W/System.err(274):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:90)
04-14 22:09:43.829: W/System.err(274):  at com.dev.coaster.SignIn.onClick(SignIn.java:71)
04-14 22:09:43.829: W/System.err(274):  at android.view.View.performClick(View.java:2408)
04-14 22:09:43.829: W/System.err(274):  at android.view.View$PerformClick.run(View.java:8816)
04-14 22:09:43.829: W/System.err(274):  at android.os.Handler.handleCallback(Handler.java:587)
04-14 22:09:43.829: W/System.err(274):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-14 22:09:43.829: W/System.err(274):  at android.os.Looper.loop(Looper.java:123)
04-14 22:09:43.829: W/System.err(274):  at android.app.ActivityThread.main(ActivityThread.java:4627)
04-14 22:09:43.829: W/System.err(274):  at java.lang.reflect.Method.invokeNative(Native Method)
04-14 22:09:43.839: W/System.err(274):  at java.lang.reflect.Method.invoke(Method.java:521)
04-14 22:09:43.839: W/System.err(274):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-14 22:09:43.839: W/System.err(274):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-14 22:09:43.839: W/System.err(274):  at dalvik.system.NativeStart.main(Native Method)
**04-14 22:09:43.839: E/SOAP Result=(274): result=null**

我的SOAP解析代码是: -

 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);    
 request.addProperty("Username","lll");

 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
 envelope.dotNet = true;
 envelope.setOutputSoapObject(request);

            Log.e("REQUEST=",""+request);
            Log.e("SOAP ENVOLP=","envolpe="+envelope);
            // Make the soap call.
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            try {

                //this is the actual part that will call the webservice
                androidHttpTransport.debug = true;
                androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                androidHttpTransport.call(SOAP_ACTION, envelope);        

                getResult = envelope.getResponse().toString();
            } catch (Exception e) {
                e.printStackTrace(); 
            }

            // Get the SoapResult from the envelope body.       
            SoapObject result = (SoapObject)envelope.bodyIn;

              Log.e("SOAP Result=","result="+result);

1 个答案:

答案 0 :(得分:2)

验证方法需要复杂的对象! 一个名为“Authenticate”的属性和两个名为“Username”和“Password”的嵌套属性。您必须在根属性中创建用于嵌套属性的复杂对象。看看这里: Nesting properties inside a tag in Ksoap2