I have implemented a WS client in Java from an existing WSDL I got.
I can connect, invoke WS methods and everything works great.
But….
I am supposed to use a Proxy for communication!!!
Already tried many ways to do that, but nothing works:
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("host",Integer.parseInt("8008")));
URL url = new URL(theUrl);
HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy);
uc.connect();
Or i tried
System.setPropertry(String, String)
So can set host and proxy and proxySet= true.
But according to colleagues this is not what I should do as it sets global properties and it will not work with many individual runs within out System.
Any ideas how I am supposed to do this?
Any help appreciated,
thanks
Eventually I used a class to extend
java.net.ProxySelectorlet’s call itMyProxySelector.javaAnd in the implemented
select()method, I check the URI, if it is a URI I which to connect through a proxy, that is the Web service’s URI then I create a proxy:add it to my proxy list:
and return the proxy list.