Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java HTTPS post using a Proxy Server

Status
Not open for further replies.

rudejohn

IS-IT--Management
Jul 11, 2003
130
US
Our application needs to use a proxy server to do an HTTPS post to a third-party data vendor. The application is nearing launch date, and all the Googling in the world hasn't helped us yet... I was wondering if anyone here might be able to send me in the right direction. Here's what we're CURRENTLY doing:

Document myXML = null;
HttpURLConnection connection = null;
Properties property = System.getProperties();

final String USERNAME = "user";
final String USERPASSWORD = "pass";

String serverName = URL url = new URL(serverName);
connection = (HttpURLConnection) url.openConnection();

property.put("http.proxyHost", "my_proxy_host");
property.put("http.proxyPort", "666");

java.net.Authenticator.setDefault(new java.net.Authenticator() {

protected PasswordAuthentication getPasswordAuthentication() {

return new java.net.PasswordAuthentication(USERNAME,
USERPASSWORD.toCharArray());
}
});

connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestProperty(
"Content-Type",
"text/xml; charset=utf-8");

connection.setRequestMethod("POST");
connection.connect();

myXML = (Document) connection.getOutputStream();


It's not even getting past the seventh line URL = new URL(String). It throws an "invalid protocol: HTTPS" error when I do an e.getMessage(). Any help? TIA,

RJ


************
RudeJohn
************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top