Tecnologia do Blogger.
RSS

[androidbrasil-dev] Re: WebService: nao consigo me comunicar por um dispositivo apenas pelo emulador

Amigo, caso o emulador esteja rodando na mesma máquina em que está o seu servidor, em vez de usar o famoso 192.168.1.102, utilize o 10.0.2.2.
Em um emulador quando vc manda ele procurar o ws no IP 192.168.1.x, ou 127.0.0.1, ele vai procurar nele mesmo ;-)
Portanto somente para emuladores rodando na mesma máquina em que está o servidor, utilize o endereço que te passei....
Abs!

Daniel

Em terça-feira, 22 de abril de 2014 10h48min47s UTC-3, Alexandre Freitas Duarte escreveu:
Olá pessoal, alguem poderia me ajudar, queria entender o que estou fazendo de errado, no emulador consigo me comunicar normal com o webservice em C#.Net, agora quando testo o app com um tablet ou celular (pelo ecplise) não funciona, ele sempre cai no "Call IOException: failed to connect to /192.168.1.102 (port 8082) after 20000ms" 

A seguir o código, meu webservice ta local.


public class WSConnection {

private static final String URL       = "http://192.168.1.102:8082/IgotYouService.svc";
private static final String NAMESPACE = "http://oriondigital.com/IgotYouService";
private static final String ACTION    = "http://oriondigital.com/IgotYouService/IIgotYou/";

public static Object call( String method, ArrayList<PropertyInfo> params)
{
Object response = null;
try
{
SoapObject request = new SoapObject(NAMESPACE, method);
PropertyInfo p = null;
for(int i = 0; i <= params.size() - 1; i++)
{
p = params.get(i);
request.addProperty(p);
}
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);

HttpTransportSE httpTransport = new HttpTransportSE (URL);

                //ERRO AQUI !!
httpTransport.call(ACTION + method, envelope);
 
response = envelope.getResponse();
Utils.Log("Response " + method + ": " + response.toString());
catch (IOException e) 
{       // MENSAGEM de ERRO !!
Utils.Log("Call IOException: " + e.getMessage());
return null;
catch (XmlPullParserException e) 
{
Utils.Log("Call XmlPullParserException: " + e.getMessage());
return null;
}
catch (Exception e) 
{
Utils.Log("Call Exception: " + e.getMessage());
return null;
}
return response;
}


--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário