Hi Justin!
I'm sorry but it doesn't work better... Has anyone another idea?
Thanks!
Virginie
-----Message d'origine-----
De : Justin Deoliveira [mailto:jdeolive@anonymised.com]
Envoyé : vendredi 19 janvier 2007 18:11
À : Virginie BERRE
Cc : geoserver-users@lists.sourceforge.net
Objet : Re: [Geoserver-users] GetFeature Java Problem
By default, the body of post requests are considered to be xml. In this
case you want the mime-type to be "application/x-www-form-urlencoded". I
beleive you can do this with the line:
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
Virginie BERRE wrote:
Hi All !
I've some troubles with Java code and hope you could help me.
I try to receive the GML response to a GetFeature request.
Let see my Java code:
String service_request_version = URLEncoder.encode("service") + "=" +
URLEncoder.encode("WFS") +"&" + URLEncoder.encode("version") + "=" +
URLEncoder.encode("1.0.0") +"&" + URLEncoder.encode("request") + "=" +
URLEncoder.encode("GetFeature");String typename = URLEncoder.encode("typename")
+ "=" + URLEncoder.encode("adresses:commune");String maxfeatures =
URLEncoder.encode("maxfeatures") + "=" + URLEncoder.encode("100");String filter = "<ogc:Filter><ogc:BBOX>" +
"<ogc:PropertyName>GEOMETRY</ogc:PropertyName>" +
"<gml:Box
xmlns:gml=\"http://www.opengis.net/gml\\" srsName=\""+srs+"\">" +"<gml:coordinates>"+xMin+","+yMin+","+xMax+","+yMax+"</gml:coordinates>"+
"</gml:Box>" +
"</ogc:BBOX></ogc:Filter>";
String filterEncoded =
"filter="+URLEncoder.encode(filter);String parameters =
service_request_version+"&"+typename+"&"+maxfeatures+"&"+filterEncoded;OutputStreamWriter osw = null;
try {
URL url = new
URL("http://localhost:8080/AdressesServices-1.0/wfs"\);HttpURLConnection connection =
(HttpURLConnection) url.openConnection();connection.setDoOutput(true);
osw = new
OutputStreamWriter(connection.getOutputStream());osw.write(parameters);
osw.flush();
BufferedReader br = new
BufferedReader(new InputStreamReader(connection.getInputStream()));String response = new String();;
String line;
while((line = br.readLine()) != null)
response += line;
br.close();
osw.close();
System.out.println(url+"?"+parameters);
System.out.println(response);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
The URL is well-formed and when I copy it on my browser, it works fine
but the response returned is :<ServiceExceptionReport version="1.2.0"
xsi:schemaLocation="http://www.opengis.net/ogc
http://localhost:8080/AdressesServices-1.0/schemas//wfs/1.0.0/OGC-exception.xsd"><ServiceException
locator="org.vfny.geoserver.util.requests.readers.DispatcherXmlReader">org.xml.sax.SAXParseException: Content is not allowed in prolog.
</ServiceException>
</ServiceExceptionReport>
If anyone could help me...
Thanks!
Best regards,
* Virginie BERRE / Ingénieur étude et développement *
Générale d'Infographie
ZA Les Erables - bâtiment 4
66 route de Sartrouville - 78232 Le Pecq Cedex
Tél. : (33) (0)1.30.15.40.50 - Fax : (33) (0)1.30.15.40.60
http://www.generale-infographie.fr/>
P / // N'imprimez ce message que si vous en avez l'utilité / ...
!DSPAM:1004,45b0da9c175561702038478!
------------------------------------------------------------------------
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV!DSPAM:1004,45b0da9c175561702038478!
------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users!DSPAM:1004,45b0da9c175561702038478!
--
Justin Deoliveira
jdeolive@anonymised.com
The Open Planning Project
http://topp.openplans.org