Friday, January 25, 2013

cfhttp in java

We had some problems with CF8 not recognizing SANs SSL certificates. The certificates were valid and properly configured, but cfhttp constantly delivered an "I/O Exception:".

The only way I could find around this was to make the calls in Java. In case it helps someone, the Java I used to make a post to a soap web service was basically as follows:

<cfsavecontent variable="requestXML"><?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">



        myUrl = "xxx"; // web service url
        objUrl = createobject("java","").init(myUrl);
        conn = objUrl.openConnection();

        //configure the request
        conn.setRequestProperty("SOAPAction", "xxx my soap action"); 
        //output stream actions
        ostream = conn.getOutputStream();
        // set input
        inS =createobject("java","").init(conn.getInputStream());
        inVar = createObject("java","").init(inS);

        builder = createObject("java","java.lang.StringBuilder").init(javacast("int",1000));
        line    = "";

           line = inVar.readLine();
           lineCheck = isDefined("line");
        } while(lineCheck);

        retvar = builder.toString();


The problems seems to be fixed in newer versions of CF.  In CF 10 I was able to make the requests to the servers with SANs certificates without a problem.

1 comment:

  1. Really its a amazing article that I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. Thank you for sharing such a great blog with us. Expecting for your update.
    Dotnet Training in Chennai