これが方法です
String NAMESPACE="あなたの名前空間";
//"http://vladozver.org/";
String METHOD_NAME = "get";//"GetStringList"; //
String SOAP_ACTION = "Your SoapAction";
//"http://vladozver.org/GetSumOfTwoInts";
String URL = "Your Soap Url";
public void involk(String na、String WebMethodName)throws IllegalStateException {
SoapObject request=new SoapObject(NAMESPACE,WebMethodName);
PropertyInfo sayHellopi=new PropertyInfo();
sayHellopi.setName("get");
sayHellopi.setValue(na);
sayHellopi.setType(String.class);
request.addProperty(sayHellopi);
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport transp = new AndroidHttpTransport(URL);
try {
transp.call(SOAP_ACTION,envelope);
//ArrayList primitive= (ArrayList) envelope.bodyIn;
SoapObject primitive= (SoapObject) envelope.bodyIn;
// SoapObject obj2=(SoapObject)obj1.getProperty(0);
// KvmSerializable ks=(KvmSerializable)envelope.bodyIn;
// System.out.println("Values.............."+envelope.bodyIn);
/* for(int i=0;i<obj2.getPropertyCount();i++){
String id1=obj2.getProperty(0).toString();
if(""!=id1 ){
System.out.println("Count " + obj2.getPropertyCount());
arraylist.add(""+id1);
System.out.println("Array ::::::::::::: " + arraylist);
}
}*/
//resText= envelope.bodyIn;
//resText = new ArrayList<Objects>();
//for(int i=0;i<resText.equals(resText);i++){
//}
System.out.println("List+++++++++++++++++");
/* //System.out.println("value of result " + primitive);
System.out.println("Count " + primitive.getPropertyCount());
//System.out.println("Prop 1 " + primitive.getProperty(0));
//System.out.println("A list b4 :; " + arrayList);*/
/* for(int i=0;i<obj1.getPropertyCount();i++){
//discount=new Discount((SoapObject)primitive.getProperty(i));
//Toast.makeText(getApplicationContext(),"Hi",Toast.LENGTH_SHORT).show();
//System.out.println("is result null????????????"+result);
arraylist.add(obj1.getPropertyCount());
System.out.println("Array ::::::::: " + arraylist);
}*/
// arraylist=new ArrayList();
//resText=new String[primitive.getPropertyCount()];
for(int i=0;i<primitive.getPropertyCount();i++){
arraylist.add((String) primitive.getProperty(i));
//arraylist.add(primitive.getPropertyCount());
System.out.println("ForLoop--------------"+primitive.getProperty(i));
// System.out.println("is result null????????????"+arrayList.listIterator());
}
// ListIterator it = arraylist.listIterator();
//while(it.hasNext())
// {
// System.out.println("arrayListValue--------------"+it.next());
//}
// System.out.println("List+++++++++++++++++"+resText.length);
// list.setAdapter(arrayadapter);
}catch (Exception e){
System.out.println("Error Value" + e);
//resText="Error Occur";
e.printStackTrace();
}
//list.setAdapter(arrayadapter);
//return "";
}
asynctaskを使用する
プライベートクラスAsyncCallはAsyncTaskを拡張します{
protected void onPreExecute(){
super.onPreExecute();
// pg.setVisibility(View.VISIBLE);
dialog=new ProgressDialog(MainActivity.this);
dialog.setIndeterminate(false);
dialog.setMessage("Loding...");
dialog.setCancelable(false);
dialog.show();
}
protected Void doInBackground(Void... parms){
involk(editText,"get");
// return null;
// return null;
return null;
}
protected void onPostExecute(Void result){
super.onPreExecute();
// tv.setText(displayText);
if(arraylist.size()!=0){
dialog.dismiss();
arrayadapter = new ArrayAdapter<String>( MainActivity.this,
android.R.layout.simple_list_item_activated_1, arraylist );
list.setAdapter(arrayadapter);
}else{
dialog.dismiss();
getError();
}
// pg.setVisibility(View.INVISIBLE);
}
}
ボタンクリックイベント
btn.setOnClickListener(new View.OnClickListener(){
public void onClick(View view) {
if(no1.getText().length()!=0&&no1.getText().length()!=0){
editText=no1.getText().toString();
AsyncCall task=new AsyncCall();
task.execute();
}
}
});
私はこれがあなたの友人を助けることを願っています:)