[Geoserver-users] [Geoserver-devel] Sending POST request - geoserver 1.4

Beate Stollberg ha scritto:

Hi,
I would like to send a GetFeature POST request using my own code.

I tried the WFS_getFeature sample as it is:

...

but it does not work.

...

What am I doing wrong?

Hum, this is the second report of this kind of issue in two days,
so I raised its priority and handled it right away.

So, the issue here is that the POST request is getting handled
as a GET request if the content type is "application/x-www-form-urlencoded", assuming the request was sent
from a browser using a form.
This is a result of fixing http://jira.codehaus.org/browse/GEOS-441.

The proper content type for wfs request seems to be "application/xml" instead. The following code works:

url = new URL("http://localhost:8080/geoserver/wfs"\);
         conn = (HttpURLConnection) url.openConnection();
         conn.setRequestMethod("POST");
         conn.setRequestProperty("Content-Type", "application/xml");
         conn.setUseCaches(false);
         conn.setDoInput(true);
         conn.setDoOutput(true);
...

Wheter this is right or not, hum, I'm not sure...
Here is the old discussion about this:
http://www.nabble.com/POST-once-more-tf2699315.html#a7530541

Hope this helps.
Cheers
Andrea Aime