• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

howto connect a webservice via a proxy server ?

 
heiner weilandt
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SOAP v1.2 gives a way to set the proxy.That should work for u.Try it out..
 
Rakesh Garishakurthi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic