Invoking Web Services through a proxy using JAX-WS
MyService service = null;
service = new MyService();
MyServiceSoap port = service.getMyServiceSoap();
BindingProvider bp = (BindingProvider) port;
Binding binding = bp.getBinding();
Map ctx = bp.getRequestContext();
ctx.put(BindingProvider.USERNAME_PROPERTY, "proxyuser");
ctx.put(BindingProvider.PASSWORD_PROPERTY, "proxypassword");
Note that we don't specify the Proxy Server here. JAX-WS sends authentication information for the proxy in request headers.
Invoking Web Services through a proxy using JAX-WS
private HttpTransportInfo getHttpInfo() {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyServer", 9090));
HttpTransportInfo httpInfo = new HttpTransportInfo();
httpInfo.setProxy(proxy);
httpInfo.setProxyUsername("proxyuser".getBytes());
httpInfo.setProxyPassword("proxypassword".getBytes());
return httpInfo;
}
Reference:
http://java-x.blogspot.hk/2009/03/invoking-web-services-through-proxy.html
留言
張貼留言