• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connect to UPS HTTPS/ssl server for Rates Web Service

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java Gurus:
I'm trying to connect to UPS's https server in order to obtain the rates information. They need the file in xml format, so i have it ready, now the problem is connecting to their https server. It keeps throwing "javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?"
I'm fighting this issue for more than a week. I have attached code snippet of the connection string information,(BTW) this info was supplied to by UPS, but they do not want to assist unless we are ready for production. Go figure....Any help would be appreciated.
try {
fName = fPath + ".xml";
XMLWriter writer = new XMLWriter(new FileWriter(fName));
writer.write(accessRequest().toString() + rateRequest().toString());
//HTTPS Connection
System.setProperty( "javax.net.debug", "SSL");// found on the internet for additional notes on error
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");//found this on javaworld for ssl connections
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());//found this on javaworld for ssl connections
URL url = new URL("https://wwwcie.ups.com/ups.app/xml/Rate:8443");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//SSLException thrown here if server certificate is invalid
conn.getInputStream();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
conn.setDoOutput(true);
PrintWriter out = new PrintWriter(conn.getOutputStream());
out.println(accessRequest().toString() + rateRequest().toString());
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
//HTTPS Connection
writer.close();

} catch (Exception ex) {
System.out.println("exception " + ex);
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic