I am new to this, I will try to be specific. I already have the web service published on the iis of a windows server 2012, I managed entity framework to access a SQLServer DB and through a webmethod insert data in a table and run the WS locally in the browser if you insert the data, up there everything is fine but, when you want to do it with android it just does not do anything. I already have the ksoap2 library installed, I have seen endless tutorials and no doubt that this is what I still have to do. I enclose my android code, I use threads for the version of android I use, otherwise it thunders, it is a method that is activated by pressing a button. thanks in advance.
public void Cita(View v) {
Thread nt = new Thread(){
EditText nombre = (EditText)findViewById(R.id.txtNombre);
EditText apellido = (EditText)findViewById(R.id.txtApellido);
EditText fecha = (EditText)findViewById(R.id.txtFecha);
EditText empleado = (EditText)findViewById(R.id.txtEmpleado);
EditText servicio = (EditText)findViewById(R.id.txtServicio);
String res;
@Override
public void run(){
String NAMESPACE = "http://tempuri.org/";
String URL = "http://192.168.1.253/ServidorWeb/SWS.asmx";
String METHOD_NAME = "AgregarCita";
String SOAP_ACTION = "http://tempuri.org/AgregarCita";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("nombre",nombre.getText().toString());
request.addProperty("apellido",apellido.getText().toString());
request.addProperty("fecha",fecha.getText().toString());
request.addProperty("idEmpleado",Integer.parseInt(empleado.getText().toString()));
request.addProperty("idServicio",Integer.parseInt(servicio.getText().toString()));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE transporte = new HttpTransportSE(URL);
try{
transporte.call(SOAP_ACTION, envelope);
SoapObject resultado = (SoapObject) envelope.getResponse();
res = resultado.toString();
res += "Agregado";
}catch(IOException e){
e.printStackTrace();
res += "Error";
}catch (XmlPullParserException e){
e.printStackTrace();
res += "Error2";
}
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(InsertaCita.this, res, Toast.LENGTH_SHORT).show();
}
});
}
};
nt.start();
}
Important fact that I ignored, regardless of giving Internet permission in the manifest, I must add this:
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService (Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork.isConnectedOrConnecting();