How to Create HTTPS Connection From J#
From: BillHouse (BillHouse_at_discussions.microsoft.com)
Date: 02/23/05
- Previous message: Chris Jones: "converting my J# application to Java"
- Next in thread: Lars-Inge Tønnessen [VJ# MVP]: "Re: How to Create HTTPS Connection From J#"
- Reply: Lars-Inge Tønnessen [VJ# MVP]: "Re: How to Create HTTPS Connection From J#"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 17:13:03 -0800
I have a need to access a 3rd-party site via HTTPS from a service-side
process. They have example code written in Java, which all works in J#
except the HTTPS connection. For that, they reference sun.* packages that I
don't think J# supports. Is there an alternative approach I can use from J#?
Here is the Java code I'm trying to port to J#:
private HttpURLConnection createConnection()
{
// Create the URL class
URL url = null;
try
{
url = new URL(HTTPS_URL);
}
catch (MalformedURLException e)
{// THIS IS THE EXCEPTION THROWN
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if(url == null)
{
return null;
}
}
// Create the connection the server
URLConnection connection = null;
try
{
connection = url.openConnection();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (NullPointerException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if(connection == null)
{
return null;
}
}
// Configure the Http connection
HttpURLConnection httpConnection = null;
httpConnection = (HttpURLConnection)(connection);
httpConnection.setDoInput(true);
httpConnection.setDoOutput(true);
try
{
httpConnection.setRequestMethod("POST");
}
catch (ProtocolException e)
{
e.printStackTrace();
}
return httpConnection;
}
- Previous message: Chris Jones: "converting my J# application to Java"
- Next in thread: Lars-Inge Tønnessen [VJ# MVP]: "Re: How to Create HTTPS Connection From J#"
- Reply: Lars-Inge Tønnessen [VJ# MVP]: "Re: How to Create HTTPS Connection From J#"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|