Pregunta

He establecido un nuevo punto de acceso en mi emulador para que pueda ver el tráfico en Fiddler siguiendo las instrucciones aquí: http://aurir.wordpress.com/2010/03/22/tutorial-getting-android-emulator-Working-with-Fiddler-http-proxy-tool /

Esto funciona para las solicitudes del navegador del emulador, pero la solicitud HTTPPOST en mi solicitud ahora está visible en Fiddler.

Aquí está el código que estoy usando:

private InputStream post(String url, Hashtable<String, String> postvariables) {

    DefaultHttpClient httpClient = new DefaultHttpClient();
    URI uri;
    InputStream data = null;

    try {
        uri = new URI(url);
        HttpPost method = new HttpPost(uri);
        method.setHeader("Content-Type","application/json");

        String param = new String();
        Enumeration<String> e = postvariables.keys();
        while(e.hasMoreElements())
        {
            String key = e.nextElement();
            param = param + key + "=" + postvariables.get(key); 
            if(e.hasMoreElements()) {
                param = param + "&";
            }
        }

        Log.i("RestClient",url + param);

        HttpEntity entity = new StringEntity(param);
        method.setEntity(entity);

        HttpResponse response = httpClient.execute(method);
        data = response.getEntity().getContent();

    } catch (Exception e) {
        e.printStackTrace();
    }

    return data;
}

¿Alguna idea de lo que estoy haciendo mal?

¿Fue útil?

Solución

I have never tried this explicitly, but have seen many reports that redirecting emulator traffic by changing the APN only affects the Browser. You might have better luck running the emulator instance with the option -http-proxy <proxy>. Look here, under Emulator Startup Options (Network) for more:

http://developer.android.com/guide/developing/tools/emulator.html

$0.02: We use Charles to debug web services and booting up the emulator in this fashion works for all traffic.

Hope that helps!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top