Boa tarde,
Meu problema é que ao executar o metodo androidHttpTransport.call(), como ele é chamado dentro do try/cat, as linhas de codigo após ele não são executadas, sendo assim nao consigo executar o envelope.getResponse().
Vou postar o codigo para ficar mais facil:
package br.login;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class LoginActivity extends Activity {
EditText etLogin;
EditText etPass;
Button btLogar;
Context context = this;
String logado = "";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//EditText - Login
etLogin = (EditText) findViewById(R.id.etLogin);
//EditText - Password
etPass = (EditText) findViewById(R.id.etPass);
//Button
btLogar = (Button) findViewById(R.id.btLogin);
btLogar.setOnClickListener(new View.OnClickListener(){
public void onClick(View arg0) {
logado = ResultLogin(etLogin.getText().toString(), etPass.getText().toString());
Builder dialogo = new AlertDialog.Builder(context);
dialogo.setTitle("Aviso");
dialogo.setMessage("Resultado: "+logado);
dialogo.setNeutralButton("OK", null);
dialogo.show();
}
});
}
public String ResultLogin(String user, String pass){
String NAMESPACE = "http://www.swingow.com/";
String URL = "http://www.swingow.com/user_vld.asmx";
String METHOD_NAME_LOGIN = "vld";
String SOAP_ACTION_LOGIN = "http://www.swingow.com/vld";
//Criando os parâmetros de entrada
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_LOGIN);
/*PropertyInfo propInfoUser = new PropertyInfo();
propInfoUser.name="cEmail";
propInfoUser.type=PropertyInfo.STRING_CLASS;
PropertyInfo propInfoPsw = new PropertyInfo();
propInfoPsw.name="cPass";
propInfoPsw.type=PropertyInfo.STRING_CLASS;
request.addProperty(propInfoUser, user);
request.addProperty(propInfoPsw, pass);*/
request.addProperty("cEmail", user);
request.addProperty("cPass", pass);
//Envelope SOAP
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.bodyOut = request;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding= \"UTF-8\"?>");
try {
//Chamada ao WS
//androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION_LOGIN, envelope);
//String com o retorno
//SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
Object resultsRequestSOAP = (Object)envelope.getResponse();
return resultsRequestSOAP.toString();
} catch (Exception e) {
//showDialog
return e.getMessage() + " FALHOU";
}
}
}
Muito Obrigado pela Ajuda!