I need to send some parameters to my web service and get result. I have used ksoap2-android-assembly-2.4-jar-with-dependencies.jar in lib, my web service work properly :
[WebMethod]
public string TestParams(string userName, string password, string startRowIndex, string maximumRows, string OrderType, string IdOpera)
{
return userName + " - " + password + " - " + startRowIndex + " - " + maximumRows + " - " + OrderType + " - " + IdOpera;
}
In main java code :
private class AsyncCall extends AsyncTask<String, Void, SoapObject > {
@Override
protected SoapObject doInBackground(String... params) {
if (Constants.DEBUG)Log.i(Constants.LOGTAG, "doInBackground");
AsynGetSellList list = new AsynGetSellList();
AsynGetSellList.setMAIN_REQUEST_URL(MAIN_REQUEST_URL);
AsynGetSellList.setMETHOD_NAME(METHOD_NAME);
AsynGetSellList.setNAMESPACE(NAMESPACE);
AsynGetSellList.setSOAP_ACTION(SOAP_ACTION);
javab = list.GetSellList(1);
return javab;
}
@Override
protected void onPreExecute() {
if (Constants.DEBUG)Log.i(Constants.LOGTAG, "onPreExecute");
pDialog = new ProgressDialog(SellList.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected void onProgressUpdate(Void... values) {
if (Constants.DEBUG)Log.i(Constants.LOGTAG, "onProgressUpdate");
}
@Override
protected void onPostExecute(SoapObject javab) {
if (Constants.DEBUG)Log.i(Constants.LOGTAG, "onPostExecute");
pDialog.dismiss();
if (isCancelled()) {
finish();
}
if (javab!=null){
fillSells(javab);
}
}
}
and GetSellList.java that include params :
public SoapObject GetSellList(int startRowIndex) {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// افزودن پارامترهای فراخوانی
request.addProperty("userName", "01395175");
request.addProperty("password", "123123");
request.addProperty("startRowIndex", "1");
request.addProperty("maximumRows", "50");
request.addProperty("OrderType", "1");
request.addProperty("IdOpera", "50");
if (Constants.DEBUG)Log.i(Constants.LOGTAG,"request = "+request);
//پاکت ساخته شده است
SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = getHttpTransportSE(MAIN_REQUEST_URL);
SoapObject javab = null;
try {
if (Constants.DEBUG)Log.i(Constants.LOGTAG,"envelope = "+envelope);
//فراخوانی وب سرویس با پاکت
androidHttpTransport.call(SOAP_ACTION, envelope);
//دریافت پاسخ از وب سرویس
// SoapObject result = (SoapObject)envelope.getResponse();
Object result0 = (Object)envelope.getResponse();
if (Constants.DEBUG)Log.i(Constants.LOGTAG,"result0 = "+result0);
SoapObject result = (SoapObject)result0;
if (Constants.DEBUG)Log.i(Constants.LOGTAG,"result = "+result);
javab = findTable(result);
} catch (Exception e) {
if (Constants.DEBUG)Log.i(Constants.LOGTAG,"Exception = "+e);
if (Constants.DEBUG)Log.i(Constants.LOGTAG,"Exception = "+e.getMessage());
e.printStackTrace();
}
return javab;
}
other code parts needed :
public PropertyInfo addParam(String name, Object value) {
PropertyInfo propertyInfo = new PropertyInfo();
propertyInfo.name = name;
propertyInfo.type = value == null ? PropertyInfo.OBJECT_CLASS : value.getClass();
propertyInfo.setValue(value);
return propertyInfo;
}
private final static SoapSerializationEnvelope getSoapSerializationEnvelope(SoapObject request) {
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = true;
envelope.setAddAdornments(false);
envelope.setOutputSoapObject(request);
return envelope;
}
what I see when I check send params in logcat :
TestParams{userName=01395175; password=password; ...}
but the problem : result0 = - - - - -
this means (to me) that web service did not receive params.
I have tested many way, but do you have enough experience to know what is problem? let me first tell that check web and changed many ways, so if you have seen or faced the same problem, let me know...Thanks.