I am trying to connect web service with kSOAP Library. code send 4 fields like username and password, name and family to the server but in server everything received null ! this is my code where is the problem? WebService.java
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.util.Log;
public class WebService {
private static String NAMESPACE = "xxxxxxxxxxxx";
public final static String URL = "xxxxxxxxxxxx";
private static String SOAP_ACTION = "xxxxxxxxxxxxxxx";
private static final String METHOD = "Register";
public static String invokeWS() {
String resTxt = null;
SoapObject request = new SoapObject(NAMESPACE, METHOD);
request.addProperty("username","user");
request.addProperty("password","pass");
request.addProperty("name","MyName");
request.addProperty("family","MyFamily");
Log.v("", ""+request);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope( SoapEnvelope.VER12);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION+METHOD, envelope);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
resTxt = response.toString();
} catch (Exception e) {
e.printStackTrace();
Log.e("",""+e);
resTxt = "Error !!!!";
}
return resTxt;
}
}
and call invokeWS() in MainActivity.java
AsyncCallWS task = new AsyncCallWS();
//Call execute
task.execute();
private class AsyncCallWS extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
displayText = WebService.invokeWS();
return null;
}
@Override
protected void onPostExecute(Void result) {
//Set response
Log.v("", "Recive : "+displayText);
}
@Override
protected void onPreExecute() {
}
@Override
protected void onProgressUpdate(Void... values) {
}
}
Add This Line To Your Code:
envelope.dotNet=true