aspose file tools*
The moose likes Web Services and the fly likes howto connect a webservice via a proxy server ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "howto connect a webservice via a proxy server ?" Watch "howto connect a webservice via a proxy server ?" New topic
Author

howto connect a webservice via a proxy server ?

heiner weilandt
Ranch Hand

Joined: Sep 10, 2002
Posts: 46
hi,
i cannot connect a webservice via a proxy.
i tried this:


i don't know what's wrong, i get an exception "Unauthorized" in the last line of this code. without a proxy and the direct input of the URL in the last line it works fine !
thanks for help
heiner
[ January 02, 2003: Message edited by: heiner weilandt ]
kishore Kumar Kota
Greenhorn

Joined: Sep 27, 2001
Posts: 16
SOAP v1.2 gives a way to set the proxy.That should work for u.Try it out..


Kishore Kumar K<br />IBM Certfied System Administrator<br />WebSphere Application Servere V5<p>Rkishore@covansys.com
Rakesh Garishakurthi
Greenhorn

Joined: Jan 13, 2003
Posts: 4
Or, Delete the properties stuff in the code and simply execute like this,
java -Dhttp.proxyHost=proxy.com -Dhttp.proxyPort=port classname.
heiner weilandt
Ranch Hand

Joined: Sep 10, 2002
Posts: 46
thanks, the way with the parameters should work, but how can i set USER and PASSWORD ?
and:
how can i set the soap 1.2 - proxy ?
can you give me an simple example ?
thanks a lot
[ January 14, 2003: Message edited by: heiner weilandt ]
john Lin
Greenhorn

Joined: Dec 03, 2002
Posts: 8
You forget to set the properties back to System before you instantiate URL
java.util.Properties prop = System.getProperties(); prop.put("proxySet","true"); prop.put("http.proxyHost","proxy.mycompany.com"); prop.put("http.proxyPort","8080");

System.setProperties(prop);

URL url = new URL("http://myService/services/myServicePort"); URLConnection conn = url.openConnection(); String password = "user ass"; String auth = "Basic " + new sun.misc.BASE64Encoder().encode(password.getBytes()); conn.setRequestProperty( "Proxy-Authorization", auth); System.out.println( "Url Connection opened"); conn.connect(); WsEmployeeServicePortType ws = new WsEmployeeServiceLocator().getWsEmployeeServicePort(conn.getURL());
heiner weilandt
Ranch Hand

Joined: Sep 10, 2002
Posts: 46
hi,
now i can use a proxy, but i don't check it out to authentificate. i always get the error "Unauthorized".
what's wrong.
the source is up !
thanks heiner
 
 
subject: howto connect a webservice via a proxy server ?