I am looking for a bit of an idea how to approach this problem. I need to access a web service. I have been supplied code to access it via PHP cURL library. However, I am using a Java/JSP server to access it. I believe this is possible (httpsURLConnection?) but I am very new to Java Development and the Java/jsp based CMS server I am working on. Any ideas/solutions would be very helpful.
Basic PHP Curl script - How would this be done in JAVA?
$id = "a.name";
$key = base64_encode("key:12345");
$url = "https://secure.server.com/$id";
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/certs/file.pem");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Auth: $key"));
// grab URL
$result = curl_exec($ch);
//result then parsed to be used as screen data