am beginning to hate java/coldfusion integration. This class is to create a
connection to a web server and return the result of that communication. It
works great in console. But when i goto use in CF I get:
Unable to find a constructor for class javaHTTPSconnection that accepts
parameters of type ( ).
Or when called with 3 strings (as the constructor below should allow):
Unable to find a constructor for class javaHTTPSconnection that accepts
parameters of type ( java.lang.String, java.lang.String, java.lang.String ).
The coldfusion code that generates this error is also below. If anyone can
point out what I am doing wrong here I would greatly appreciate it.
----------------------------------CF Code ------------------------
<cfset connection =
CreateObject("java","javaHTTPSconnection").init("#Myquery.Processing_Server#",
"#Myquery.Username#:#Myquery.Password#", "#string_270#")>
----------------------------------JAVA CLASS ------------------------
import java.net.URL;
import java.io.*;
import javax.net.ssl.HttpsURLConnection;
public class javaHTTPSconnection {
String httpsURL;
String UserPass;
String AuthHeaderEnc;
String Body;
javaHTTPSconnection(){
httpsURL = "URL"; //removed URL
UserPass = "user:pass"; // removed user + Pass
AuthHeaderEnc = "basic " + Base64.encodeBytes(UserPass.getBytes());
Body = "Test";
}
javaHTTPSconnection(String a, String b, String c){
httpsURL = a;
UserPass = b;
AuthHeaderEnc = "basic " + Base64.encodeBytes(UserPass.getBytes());
Body = c;
}
void SetKeyStore(){
//Set Keystore for this class
System.setProperty("javax.net.ssl.keyStore",
"C:\\jclasses\\jssecacerts");
System.setProperty("javax.net.ssl.keyStoreType", "JKS");
System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
System.setProperty("javax.net.ssl.trustStore",
"C:\\jclasses\\jssecacerts");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStorePassword",
"changeit");
}
public String[] HTTPScon ()
throws Exception
{
String retvar[] = new String[5000];
int i = 0;
System.out.println(AuthHeaderEnc);
SetKeyStore();
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
con.setRequestProperty("Authorization", AuthHeaderEnc);
con.setRequestProperty("charset", "us-ascii");
con.setRequestProperty("Content-Length",
String.valueOf(AuthHeaderEnc.length()));
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
OutputStream out = con.getOutputStream();
out.write(Body.getBytes());
System.out.println(con.toString()+"\n\n");
InputStream ins = con.getInputStream();
InputStreamReader isr=new InputStreamReader(ins);
InputStreamReader isr2=new InputStreamReader(ins);
BufferedReader in =new BufferedReader(isr);
String inputLine;
in.mark(5000);
while ((inputLine = in.readLine()) != null){
retvar[i] = inputLine;
i++;
}
in.close();
return retvar;
} //end HTTPScon
}// end class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:269841
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4