hola a todos, soy novato en cuanto a las app y estoy realizando una app que consume un web service que es este:
Código:
public class DemoWS extends Activity
{
TextView text1;
private static final String namespace = "http://tempuri.org/";
private static String url="http://localhost:50190/Service1.asmx";
private static final String Metodo_helloworld = "HelloWorld";
private static final String accionSoap_hello ="http://tempuri.org/HelloWorld";
private static final String Metodo_getbooktitle = "GetBooksByTitle";
private static final String accionSoap_title ="http://tempuri.org/GetBooksByTitle";
private static final String Metodo_getbookautor = "GetBooksByAuthor";
private static final String accionSoap_autor ="http://tempuri.org/GetBooksByAuthor";
private Button botonhello;
private Button botonautor;
private Button botontitle;
//private Object NombreUsuario;
//private Object PassUsuario;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text1= (TextView) findViewById(R.id.text1);
botonautor = (Button) findViewById(R.id.btautor);
botontitle = (Button) findViewById(R.id.bttitle);
botonhello = (Button) findViewById(R.id.bthello);
botonhello.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
hello();
}
}) ;
botonautor.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
autor();
}
}) ;
botontitle.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
title();
}
}) ;
}
public void hello()
{
SoapObject solicitud = new SoapObject(namespace, Metodo_helloworld);
SoapSerializationEnvelope envoltorio = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envoltorio.dotNet = true;
envoltorio.setOutputSoapObject(solicitud);
HttpTransportSE transporte = new HttpTransportSE(url);
try {
transporte.call(accionSoap_hello, envoltorio);
// Object result = (Object)envoltorio.getResponse();
java.lang.String CadenaDevuelta =(String) envoltorio.getResponse();
text1.setText(CadenaDevuelta);
// text1.setText(result.toString());
}
catch (Exception e)
{
text1.setText(e.getMessage());
}
}
public void autor()
{
SoapObject solicitud = new SoapObject(namespace, Metodo_getbookautor);
SoapSerializationEnvelope envoltorio = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envoltorio.dotNet = true;
envoltorio.setOutputSoapObject(solicitud);
HttpTransportSE transporte = new HttpTransportSE(url);
try {
transporte.call(accionSoap_autor, envoltorio);
Object result = (Object)envoltorio.getResponse();
text1.setText(result.toString());
}
catch (Exception e)
{
text1.setText(e.getMessage());
}
}
public void title()
{
SoapObject solicitud = new SoapObject(namespace, Metodo_getbooktitle);
SoapSerializationEnvelope envoltorio = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envoltorio.dotNet = true;
envoltorio.setOutputSoapObject(solicitud);
HttpTransportSE transporte = new HttpTransportSE(url);
try {
transporte.call(accionSoap_title, envoltorio);
Object result = (Object)envoltorio.getResponse();
text1.setText(result.toString());
}
catch (Exception e)
{
text1.setText(e.getMessage());
}
}
}
pero al ejecutarlo me sale localhost:50190 connection refused alguien me puede ayudar???
nota: ya he cambiado el localhost por mi ip y tampoco funciona , mi app la ejecuto en un dispositivo no en la virtual