unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@4607eb40)

2,576 views
Skip to first unread message

fabi...@co-rising.com

unread,
Jan 21, 2013, 1:40:21 AM1/21/13
to ksoap2-...@googlegroups.com

i write a simple sample and i get the exception:
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@460ae588) 
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@460ae588) 
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1420)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:214)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at com.example.ksoap_android_authentication_demo.MainActivity.action(MainActivity.java:75)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at com.example.ksoap_android_authentication_demo.MainActivity.access$0(MainActivity.java:51)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at com.example.ksoap_android_authentication_demo.MainActivity$1.onClick(MainActivity.java:45)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at android.view.View.performClick(View.java:2408)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at android.view.View$PerformClick.run(View.java:8817)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at android.os.Handler.handleCallback(Handler.java:587)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at android.os.Handler.dispatchMessage(Handler.java:92)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at android.os.Looper.loop(Looper.java:144)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at android.app.ActivityThread.main(ActivityThread.java:4937)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at java.lang.reflect.Method.invokeNative(Native Method)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at java.lang.reflect.Method.invoke(Method.java:521)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-21 14:22:16.642: E/com.example.ksoap_android_authentication_demo.MainActivity(13568): at dalvik.system.NativeStart.main(Native Method)

here is my code:

package com.example.ksoap_android_authentication_demo;


import java.util.ArrayList;

import java.util.List;


import org.ksoap2.HeaderProperty;

import org.ksoap2.SoapEnvelope;

import org.ksoap2.serialization.PropertyInfo;

import org.ksoap2.serialization.SoapObject;

import org.ksoap2.serialization.SoapSerializationEnvelope;

import org.ksoap2.transport.HttpTransportSE;


import android.app.Activity;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.TextView;


public class MainActivity extends Activity implements OnClickListener {

private static final String SOAP_ACTION = "http://schemas.microsoft.com/sharepoint/soap/GetList";

// List Web Service:

// http://www.runmont.com:1093/test/_vti_bin/lists.asmx?op=GetList

private static final String METHOD_NAME = "GetList";

private static final String NAMESPACE = "http://schemas.microsoft.com/sharepoint/soap/";

private static final String URL = "http://www.runmont.com:1093/test/_vti_bin/lists.asmx";

private static final String TAG = MainActivity.class.getName();

private TextView responseTextView;


@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);


responseTextView = (TextView) findViewById(R.id.response);

findViewById(R.id.action).setOnClickListener(this);

}


@Override

public void onClick(View v) {

PropertyInfo pi = new PropertyInfo();

pi.setName("listName");

pi.setValue("Calendar");

pi.setType(String.class);


SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

request.addProperty(pi);


String authentication = android.util.Base64.encodeToString(

"myuse...@runmont.com:mypassword".getBytes(),

android.util.Base64.NO_WRAP);

List<HeaderProperty> headers = new ArrayList<HeaderProperty>();

headers.add(new HeaderProperty("Authorization", "Basic "

+ authentication));

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(

SoapEnvelope.VER11);

envelope.dotNet = true;

envelope.bodyOut = request;

envelope.setOutputSoapObject(request);

HttpTransportSE transport = new HttpTransportSE(URL);

try {

transport.debug = true;

transport.call(SOAP_ACTION, envelope, headers);

Object result = envelope.getResponse();

Log.i(TAG, "result = " + result);

responseTextView

.setText(result == null ? null : request.toString());

} catch (Exception e) {

Log.e(TAG, e.getMessage(), e);

responseTextView.setText(e.getMessage());

}


}

}

the source code also can be found in attachment.

i got this exception and i searched a lot but i can't fixed. any help? thanks!

(it is run on android 2.2 with ksoap2-android-assembly-2.6.5-jar-with-dependencies.jar)

ksoap-android-authentication-demo.zip

Robert Gustavsson

unread,
Jan 21, 2013, 3:47:09 AM1/21/13
to ksoap2-...@googlegroups.com
Hi Fabin!
 
I would try the latest version of ksoap2 (3.0.0 RC4). Then turn on debug (.debug = true; on your HttpTransportSE object) to be see the xml data, save it as an xml file and check that it is correct. Then I would download the source code for ksoap2 and dependant libraries to find out more about why the exception was thrown. Maybe it would help you troubleshoot if you set up your environment to be able to compile and step through ksoap2 and kxml2.
 
Have you tried:
 
envelope.dotNet = true;
envelope.implicitTypes = true;
/rob

fabi...@co-rising.com

unread,
Jan 21, 2013, 4:22:46 AM1/21/13
to ksoap2-...@googlegroups.com
i tried envelope.implicitTypes = true; it not work.

i would try using the source code.
thx!

fabi...@co-rising.com

unread,
Jan 21, 2013, 6:00:29 AM1/21/13
to ksoap2-...@googlegroups.com

i found it!

in HttpTransportSE.call(String soapAction, SoapEnvelope envelope, List headers, File outputFile), reponseCode is not checked.

in my case, reponseCode == 401, so contentLength == 0, exception thrown when new BufferedInputStream.


i add getResponseCode() and getResponseMessage() in interface ServiceConnection add check reponseCode before  instance BufferedInputStream:

int reponseCode = connection.getResponseCode();

if (reponseCode != 200) {

throw new RuntimeException("reponse code:" + reponseCode + "; "+ connection.getResponseMessage());

}

i don't know if it is the best way.

On Monday, January 21, 2013 4:47:09 PM UTC+8, Robert Gustavsson wrote:

Robert Gustavsson

unread,
Feb 6, 2013, 4:04:25 PM2/6/13
to ksoap2-...@googlegroups.com
That sounds like something similar to what I did. But in my case I got a SOAP response back. I had to check for  the SOAP embedded error before trying to deserialize any data. Same same, but different.

/rob
Reply all
Reply to author
Forward
0 new messages