How to Create HTTPS Connection From J#

From: BillHouse (BillHouse_at_discussions.microsoft.com)
Date: 02/23/05

  • Next message: burtr: "J# java.util.Calendar bug????????"
    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;
            }


  • Next message: burtr: "J# java.util.Calendar bug????????"

    Relevant Pages

    • Re: Cannot access https or windowsupdate
      ... Can't access HTTPS Pages ... Because of a court decision Microsoft will stop all Java support after 30 ... Sun also offers an automatic download and install of the 1.4 Java plug-in ... You might also try installing the Windows Script 5.6 for Windows 2000 and XP ...
      (microsoft.public.windows.inetexplorer.ie6.browser)
    • Re: Securing a Java Application
      ... I have a Java application that uses JSP for visualizing data and EJB for queries. ... I need to create a Java client that connects to the J2ee application. ... using Secure Sockets? ... The existing Java Http comms classes can already handle the https protocol for you. ...
      (comp.lang.java.programmer)
    • Re: Securing a Java Application
      ... I have a Java application that uses JSP for visualizing data and EJB for queries. ... using Secure Sockets? ... The existing Java Http comms classes can already handle the https protocol for you. ... If your server cert isn't 'official' I think the client code has to override some security provider setting somewhere in order to function... ...
      (comp.lang.java.programmer)
    • Re: Question on HTTP interfacing (Java/C++)
      ... >without https you are on your own. ... You will have to encrypt the messages ... Mixing languages triples your problem. ... One way out of this that you boss may allow is to use Java on both ...
      (comp.lang.java.programmer)
    • Re: Question on HTTP interfacing (Java/C++)
      ... >>without https you are on your own. ... You will have to encrypt the messages ... then have Java decrypt and hand off to C++. ... examples exposing EJB components as COM components to VB apps (but the ...
      (comp.lang.java.programmer)

    Loading