java httpconnection wfs
------------------------
Key: GEOS-326
URL: http://jira.codehaus.org/browse/GEOS-326
Project: GeoServer
Type: Test
Environment: j2me + tomcat + oracle
Reporter: yyt wyy
Assigned to: Chris Holmes
when i try to make a http request in j2me like"http://localhost:8090/geoserver/wfs?request = getfeature &typename=topp:bc_roads",
the java code is:
HttpConnection hpc = null;
DataInputStream dis = null;
byte data = null;
try {
hpc = (HttpConnection) Connector.open("http://localhost:8090/geoserver/wfs?request = getfeature &typename=topp:bc_roads");
int length = (int) hpc.getLength();
String str = hpc.getType() ;
dis = new DataInputStream(hpc.openDataInputStream());
byte buf1 = new byte[1024];
byte buf = new byte[1024 * 64];
int total = 0;
int grab = 0;
while ( (grab = dis.read(buf1)) > -1) {
System.arraycopy(buf1, 0, buf, total, grab);
total += grab;
}
data = new byte[total];
System.arraycopy(buf, 0, data, 0, total);
}
finally {
if (hpc != null) {
hpc.close();
}
if (dis != null) {
dis.close();
}
}
return data;
encouter erro :
java.io.IOException: Server returned HTTP response code: 505 for URL:
http://localhost:8090/geoserver/wfs?request = getfeature &typename=topp:bc_roads
why this happen ,I tried it with j2se,it got the same erro,
j2se code:
public byte readImg() throws IOException {
URL url = new URL("http://localhost:8090/geoserver/wfs?request = getfeature &typename=topp:bc_roads");
URLConnection uc ;
byte data ;
DataInputStream dis = null;
Image image = null;
try {
uc = url.openConnection();
int length = (int) uc.getContentLength();
String str = uc.getContentType();
uc.getInputStream();
uc.getContent();
dis = new DataInputStream(uc.getInputStream());
byte buf1 = new byte[1024];
byte buf = new byte[1024 * 64];
int total = 0;
int grab = 0;
while ( (grab = dis.read(buf1)) > -1) {
System.arraycopy(buf1, 0, buf, total, grab);
total += grab;
}
data = new byte[total];
System.arraycopy(buf, 0, data, 0, total);
}
finally {
if (dis != null) {
dis.close();
}
}
return data;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira