Define source ip address using Apache HttpClient

You just need to tell HttpClient which network interface to use. You can do this with a connection property:

ConnRoutePNames.LOCAL_ADDRESS='ADDRESS A';

check out section 2.4 of the docs for a full description.

final DefaultHttpClient httpClient = new DefaultHttpClient();
HttpParams params = httpClient.getParams();
params.setParameter(ConnRoutePNames.LOCAL_ADDRESS, InetAddress.getByName(IP_ADDRESS));