I'm just trying to send a request and read out the answer of an ogc sos server.
sent request:
connection = new URL(url).openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Accept-Charset", charset);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset="+charset);
connection.connect();
read response:
output = connection.getOutputStream();
output.write(query.getBytes(charset));
input = new URL(url).openStream();
Reader reader = new InputStreamReader(input);
BufferedReader bufferedReader = new BufferedReader(reader);
StringBuilder response = new StringBuilder();
String line = null;
while((line = bufferedReader.readLine()) != null)
response.append(line+"\n");
bufferedReader.close();
output.close();
The response of the server is:
<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0"
xsi:schemaLocation="http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd">
<ows:Exception exceptionCode="InvalidRequest" locator="REQUEST">
<ows:ExceptionText>The GET request null is not supported by this SOS.</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>
The format is a special sos type, but the main message is "The GET request null" So it seem like the server read the request by GET method.
I am not that firm in networking, but as I understood, I ensure by setDoOutput(true);
to use the POST method, isn't it?
As I get any answer, I know there is a connection, but may it be that something with the head is wrong? Is it necessary in every case to sent it?
So my question is just what could be the reason what makes me or the server confusing about the http methods?
I guess I am missusing the java network handling.
Would be glad about every help.