実際、私はAndroidアプリを開発しています....net Webサービスから100行以上をフェッチする必要があります..(ksoap2を使用)..しかし、Webサービスを呼び出すと、100をフェッチする代わりにソケットタイムアウト..例外..が発生します行私は30行でフェッチしようとしました..うまくいきました..だから、問題が.net Webサービスにあるのか、それとも私のアンドロイドにあるのか、問題を認識できません。その間に大量のデータを取得する別の方法があるかどうかを知りたいだけです。
権限も追加しました:
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
コード:
package school.demo;
import java.util.ArrayList;
import java.util.HashMap;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
public class Code extends Activity {
Button b1;
TextView t1;
String s = "11-10-2012";
int c = 0, j = 0;
ArrayList<String> al = new ArrayList<String>();
HashMap<String, String> map;
private static final String NAMESPACE = "http://TestClass/";
private static final String URL = "http://***.**.**.**/TestClass/Service1.asmx";
private static final String HelloWorld_SOAP_ACTION1 = "http://TestClass/getdata";
private static final String METHOD_NAME2 = "getdata";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.accounts);
GridView g1 = (GridView) findViewById(R.id.gridView1);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME2);
request.addProperty("Uname", s);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.setTimeout(MODE_WORLD_READABLE);
try {
httpTransport.call(HelloWorld_SOAP_ACTION1, envelope);
SoapObject res = (SoapObject) envelope.getResponse();
SoapObject root = (SoapObject) res.getProperty(0);
SoapObject s_deals = (SoapObject) root.getProperty("Table1");
String s = s_deals.toString();
httpTransport.requestDump="TRUE";
// Toast.makeText(getApplicationContext(), s,
//Toast.LENGTH_LONG).show();
for (int i = 1; i < root.getPropertyCount(); i++) {
Object o = root.getProperty(i);
SoapObject main = (SoapObject) o;
String f1 = main.getProperty(1).toString();
String f2 = main.getProperty(2).toString();
String f3 = main.getProperty(3).toString();
String f4 = main.getProperty(4).toString();
String f5 = main.getProperty(5).toString();
//String f6 = main.getProperty(6).toString();
al.add(f1);
al.add(f2);
al.add(f3);
}
@SuppressWarnings("unchecked")
ArrayAdapter a1 = new ArrayAdapter(Code.this, R.layout.blows,
R.id.textView1, al);
g1.setAdapter(a1);
g1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), " " + arg2,
Toast.LENGTH_LONG).show();
}
});
} catch (Exception e) {
Toast.makeText(getApplicationContext(), e.toString(),
Toast.LENGTH_LONG).show();
}
}
}