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:Filterogc:BBOX” +
“ogc:PropertyNameGEOMETRY</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 :
org.xml.sax.SAXParseException: Content is not allowed in prolog.
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 mailto:vberre@anonymised.com81… http://www.generale-infographie.fr |
---|
P N’imprimez ce message que si vous en avez l’utilité …