Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cannot read response from https url connection

2 views
Skip to first unread message

Terri I.

unread,
Nov 21, 2001, 10:22:10 AM11/21/01
to
I've got a Java class that establishes a connection to an https URL -
it seems to connect fine and post data to the server fine. However,
when I try to read the response sent from the server (a cgi script in
this case), I get a java.lang.ArrayStoreException error. How can I
read a response sent over an https connection?? The code worked fine
when I was testing connecting to http URL.

Here is the code, followed by the output of the printstacktrace
command:

CODE:
import oracle.sql.CLOB;
import oracle.sql.*;
import java.security.*;
import java.net.URL;
import java.net.*;
import java.io.*;

public class ManageSSLConnection{
// POST an XML document to a Service's URL, returning response

public static String sendXMLoverSSL(oracle.sql.CLOB xmlToPost,
String target) {
String response = "No TIME data posted to Visualization server.";

try {
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider());

// Open an HTTP connection to the target URL
HttpURLConnection conn = null;
URL vistarget = new URL(target);
conn = (HttpURLConnection)vistarget.openConnection();
if (conn == null) return "Error connecting to Visualization
server.\n\n";

// Use HTTP POST
conn.setRequestMethod("POST");

// Indicate that the content type is XML with appropriate MIME
type
conn.setRequestProperty("Content-type","text/xml");

// Set up for writing and reading from the connection
conn.setDoOutput(true);
conn.setDoInput(true);
conn.connect();

// Read from the CLOB stream and write to a string
String xml_string = xmlToPost.getSubString(1L,
(int)xmlToPost.length());

// Write the XML document into the connection's output stream
DataOutputStream out = new
DataOutputStream(conn.getOutputStream());
out.writeBytes(xml_string);
out.flush();
out.close();

// Get header response from the server

// Need to call getHeaderFieldKey method so that
// getResponseCode and getResponseMessage methods will
// not return FileNotFoundException when return code > 400.
// This is a known Java bug that is expected to be fixed in v.
1.4


int resp_code = conn.getResponseCode();
String resp_msg = conn.getResponseMessage();
response = resp_code + " " + resp_msg;

conn.disconnect();

return response + "\n\n";
}

catch (FileNotFoundException e1) {
return("Java FileNotFoundException\n\n");
}

catch (IOException e2) {
e2.printStackTrace();
return(response + " Java IOException\n\n");
}

catch (Exception e3) {
e3.printStackTrace();
return(response + " Unknown Java Exception\n\n");
}
}
}


Here is the trace info:
Dump file /u01/app/oracle/admin/visual/udump/visual_ora_347.trc
Oracle8i Enterprise Edition Release 8.1.7.2.0 - Production
With the Partitioning option
JServer Release 8.1.7.2.0 - Production
ORACLE_HOME = /u01/app/oracle/product/8.1.7
System name: SunOS
Node name: surge-dev
Release: 5.6
Version: Generic_105181-23
Machine: sun4u
Instance name: visual
Redo thread mounted by this instance: 1
Oracle process number: 13
Unix process pid: 347, image: oracle@surge-dev (TNS V1-V3)

*** 2001-11-21 10:20:05.129
*** SESSION ID:(15.56179) 2001-11-21 10:20:05.105
java.lang.ArrayStoreException
at java.lang.System.arraycopy(System.java)
at java.util.Vector.copyInto(Vector.java:156)
at com.sun.net.ssl.internal.www.protocol.https.ChunkedInputStream.c([DashoPro-
V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.ChunkedInputStream.<init>([Dash
oPro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.b([DashoPro-V1.2-120
198])
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.a([DashoPro-V1.2-120
198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getInputStre
am([DashoPro-V1.2-120198])
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:145)
at ManageSSLConnection.sendXMLoverSSL(ManageSSLConnection.java:68)

Don

unread,
Nov 27, 2001, 12:13:47 PM11/27/01
to
ter...@ucia.gov (Terri I.) wrote in message news:<b1f8b3bc.01112...@posting.google.com>...

> I've got a Java class that establishes a connection to an https URL -
> it seems to connect fine and post data to the server fine. However,
> when I try to read the response sent from the server (a cgi script in
> this case), I get a java.lang.ArrayStoreException error. How can I
> read a response sent over an https connection?? The code worked fine
> when I was testing connecting to http URL.
>
SNIP

In the JSSE doc, it says you can view all debugging messages by
specifying the following property: javax.net.debug=all

i.e.,

from the command line

java -Djavax.net.debug=all MyApp

This lets you see the messages before encryption and after decryption.

Terri I.

unread,
Nov 28, 2001, 2:51:47 PM11/28/01
to
Yeah, I did that - all it showed me was that SSL seems to be working
(i.e., I saw the certificates being passed and the data being sent in
encrypted format). But it does not show why the ArrayStoreException
is being thrown.


junkmai...@yahoo.com (Don) wrote in message news:<c08f3424.0111...@posting.google.com>...

0 new messages