Link to home
Start Free TrialLog in
Avatar of Sujay1000
Sujay1000

asked on

Https URL Connection Issue

Created URL object.
java.io.IOException: Server returned HTTP response code: 411 for URL: https://ABCD
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
      at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getInputStream(Unknown Source)
      at com.medco.cti.oracle.TEST.main(TEST.java:35)

Authenticator.setDefault(new MyAuthenticator());
			System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
			Class clsFactory = Class.forName("com.sun.net.ssl.internal.ssl.Provider");
 
			if ((clsFactory != null) && (Security.getProvider("SunJSSE") == null))
			{
			Security.addProvider((Provider)clsFactory.newInstance());
			}
 
			URL myURL = new URL("https://ABCD");
			System.out.println("Created URL object.");
			 // Install the custom authenticator
		    
			HttpsURLConnection connection = (HttpsURLConnection)myURL.openConnection();
			connection.setDoOutput(true);
			connection.setRequestMethod("POST");
			connection.setRequestProperty("Content-Type", "text/xml; charset=UTF-8"); 
			connection.setRequestProperty("Authorization", "Basic " + "Q1RJUFJPRDpQI0NUSTA5");
			connection.getInputStream();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial