Discussions

XML & Web services: Send SOAP Messages Over HTTPS With WSAD 5.0

  1. Send SOAP Messages Over HTTPS With WSAD 5.0 (2 messages)

    Hello everyone,

    I have a program that sends (and receives) SOAP messages
    over HTTPS. The program works fine with SUN JDK 1.3.1
    (and SUN JDK 1.4.1). I get an exception when I run the
    same program with WebSphere Studio 5.0 GA (as a standalone program)
    using IBM JDK 1.3.1. I have done the following:

    copy jcert.jar, jnet.jar and jsse.jar
    in the <WSAD 5>\runtimes\base_v5\java\jre\lib\ext directory.
    (I also tried it with <WSAD 5>\eclipse\jre\lib\ext directory).
    Those jar files are also added to the classpath.

    edit the corresponding java.security file to have:
    security.provider.1=sun.security.provider.Sun
    security.provider.2=com.sun.net.ssl.internal.ssl.Provider

    add the following lines to my java program:
    System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    Has anyone had any success in trying this?
    This is the exception that I get:

    java.net.UnknownHostException: d1.bconline.gov.bc.cagsweb
    at java.net.InetAddress.getAllByName0(InetAddress.java:591)
    at java.net.InetAddress.getAllByName0(InetAddress.java:560)
    at java.net.InetAddress.getByName(InetAddress.java:469)
    at java.net.Socket.<init>(Socket.java:121)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:65)
    at sun.net.NetworkClient.openServer(NetworkClient.java:52)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:578)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:291)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:252)
    at com.sun.xml.messaging.saaj.client.p2p.http.handler.HttpURLConnection.connect(HttpURLConnection.java:445)
    at com.sun.xml.messaging.saaj.client.p2p.http.handler.HttpURLConnection.followRedirect(HttpURLConnection.java:825)
    at com.sun.xml.messaging.saaj.client.p2p.http.handler.HttpURLConnection.getInputStream(HttpURLConnection.java:582)
    at com.sun.xml.messaging.saaj.client.p2p.http.handler.HttpURLConnection.getHeaderField(HttpURLConnection.java:878)
    at com.sun.xml.messaging.saaj.client.p2p.http.handler.HttpURLConnection.getResponseCode(HttpURLConnection.java:905)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:258)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:142)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:115)
    at ca.mda.webservices.SecureTest.main(SecureTest.java:137)
    java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:289)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:142)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:115)
    at ca.mda.webservices.SecureTest.main(SecureTest.java:137)
    javax.xml.soap.SOAPException: java.security.PrivilegedActionException < at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:121)
    at ca.mda.webservices.SecureTest.main(SecureTest.java:137)


    Thanks for any help,
    Richard

    Threaded Messages (2)

  2. Send SOAP Messages Over HTTPS With WSAD 5.0[ Go to top ]

    Just a thought. The API you are using is wrapping up the HTTPURLConnection Class. I wrote an XML Messaging SSL client and I use just the plain URLConnection class. It took me a lot of investigation to get this working and I believe the reason I did that was because you cannot use https:// when doing HTTPURLConnection on http://. (i.e. No "s" in it)

    Here is my post method

    public String post(String postData) throws BridgeException
    {
    //*********************************************************************
    //***** Setting the HTTPS Properties **********************************
    //*********************************************************************

    Class factoryClass = null;
    URLStreamHandlerFactory factory = null;
    String socksServer = null;
    String socksPort = null;

    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    Properties properties = System.getProperties();
    String handlers = System.getProperty("java.protocol.handler.pkgs");

    if (handlers == null)
    {
    properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    }
    else
    {
    properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol|".concat(handlers));
    }

    System.setProperties(properties);


    //*********************************************************************
    //***** Posting the Data **********************************************
    //*********************************************************************

    URLConnection ucon;
    String fullURL = transformer.attIPAddress;

    try
    {
    URL baseurl = new URL(fullURL);

    ucon = baseurl.openConnection();

    ucon.setUseCaches(false);
    ucon.setDoOutput(true);
    ucon.setDoInput(true);
    ucon.setAllowUserInteraction(false);

    ucon.setRequestProperty("Content-Type","text/xml");
    ucon.setRequestProperty("Content-Length", String.valueOf(postData.length()));
    ucon.setRequestProperty("Authorization", "Basic " + String.valueOf(Base64.encode("IBM2000:IBM2000")));

    PrintStream out = new PrintStream(ucon.getOutputStream());
    out.print("POST " + fullURL + " HTTP/1.1");
    out.print(postData.toString());

    if (out.checkError())
    {
    log("Error Connecting to ATT");
    throw new Exception("Error Writing Data onto the Stream");
    }
    }
    catch(Exception e)
    {
    log("POSTING TO ATT :Problem in posting: " + e.toString() + e.getMessage());
    e.printStackTrace();
    throw new BridgeException(e.toString());
    }
       
     

    //*********************************************************************
    //***** Handling the Response ****************************************
    //*********************************************************************

      
    try
    {
    String strXml;
    String response;

    BufferedReader in = new BufferedReader(new InputStreamReader(ucon.getInputStream()));
    StringBuffer document = new StringBuffer();
    String line;

    while ((line=in.readLine()) != null )
    {
    document.append(line);
    }
    in.close();

    strXml = document.toString();
    strXml = strXml.trim();

    response = parseResponse(strXml);
    log("IBMRECEIVER : XML response from ATT:" + strXml);
    log("IBMRECEIVER : XML response :" + response);

    return response;

    }
    catch(Exception exception)
    {
    log("Fail: Problem in Reading in ATT Response XML: " + exception.toString());
    exception.printStackTrace();
    throw new BridgeException(exception.toString());
    }
    }
  3. Urgent Help[ Go to top ]

    Hey.. M doing a project where in m supposed to develop a HTTP Web Server which can process SOAP enveloped XML Messages..... hav just managed to create a normal HTTP Web Server.. Stuck... Need Help.. If you could share your code wid me... Thanks a million