ASMX Webサービスを呼び出したい、doInBackground からSoapObjectまたはList in activityを取り戻す方法、Webサービスは正常 に機能し、ログファイルに値を表示します。コードは、Webサービスを呼び出している間ファイルです。
import java.io.IOException;
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 org.xmlpull.v1.XmlPullParserException;
import android.util.Log;
public class WebserviceMainCategory {
static String SOAP_ACTION = "http://tempuri.org/loadProductCatagory";
static String METHOD_NAME = "loadProductCatagory";
static String NAME_SPACE = "http://tempuri.org/";
static String URL = "http://74.53.87.146/seharwebservice/Service.asmx";
public List<String> main_items = new ArrayList<String>();
public static String[] namess ;
static int s ;
public static SoapObject soap;
public SoapObject webServiceMain_list() {
SoapObject request = new SoapObject(NAME_SPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = true;
envelope.setAddAdornments(false);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransportSe = new HttpTransportSE(URL);
httpTransportSe.debug = true;
try {
httpTransportSe.call(SOAP_ACTION, envelope);
Object result = envelope.getResponse();
soap = (SoapObject) result;
/*
SoapObject result2nd = (SoapObject) result;
s = result2nd.getPropertyCount();
//String[]arrayLis = new String[s];
namess = new String[s];
for(int i=0; i<result2nd.getPropertyCount(); i++)
{
Log.d("ddd", result2nd.getPropertyAsString(i));
namess[i]=result2nd.getPropertyAsString(i);
Log.d("array", namess[i]);
main_items.add(result2nd.getPropertyAsString(i));
}
*/
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
return soap;
}
}
ここで、AsyncTaskクラスを作成します
class Main_itemsList extends AsyncTask<Void, Void, SoapObject> {
@Override
protected SoapObject doInBackground(Void... params) {
WebserviceMainCategory mAuth = new WebserviceMainCategory();
return mAuth.webServiceMain_list();
}
public void execute(SoapObject aa) {
}
}
主な活動で応答を得る方法、
私の活動のコードのように
SoapObject soap = new Main_itemsList()。execute();
私たちの
ListArray aa = new Main_itemsList()。execute();
ありがとう..