Ok, I see what you want.
So try jersey with apache client:
HostConfiguration hostConfiguration = new HostConfiguration();
byte b[] = new byte[4];
b[0] = new Integer(192).byteValue();
b[1] = new Integer(168).byteValue();
b[2] = new Integer(1).byteValue();
b[3] = new Integer(11).byteValue();
hostConfiguration.setLocalAddress(InetAddress.getByAddress(b));
HttpClient client = new HttpClient();
client.setHostConfiguration(hostConfiguration);
Something like that. I hope this help.
Regards,
Petr
2011/2/11 Christopher Piggott <cpiggott_at_gmail.com>:
> On Fri, Feb 11, 2011 at 9:16 AM, Petr Jurák <petr.jurak_at_gmail.com> wrote:
>> Hello,
>> Try something like this:
>>
>> Client c = Client.create();
>> WebResource r = c.resource(“http://youripaddress:8080/xyz”);
>
> I'm not sure what you mean, that's the normal way of doing it ... but
> it doesn't manipulate the source address of the socket.
>
> What I want to be able to do is more like:
> r = c.resource("http://something:port/something", MY_ETH_ADDR);
> or
> r = c.resource("http://something:port/something", MY_CELL_ADDR);
>
> in order to set the source address, on a WebResource by WebResource
> basis. At that point, the ip routing policy I set up will route out
> the interface that is bound to that source address. Of course, the
> above methods don't exist.
>
> What I am trying to figure it is a reasonable way to do this within
> the existing jersey client framework. As Pavel pointed out, the
> jersey-apache-client might have a way, but I haven't found it yet.
>
> Maybe the answer is "Don't use jersey-client" :-( but jersey-client
> is sooooo nice ... the URI builder, the message body readers and
> provider framework.... I hate to give that up because of something
> that should be so simple.
>
> --Chris
>