[Geoserver-devel] Transaction requests

Hi all !!

I'm new to GeoServer but I installed it properly on Windows, and it's connected to a PostGIS Database on Solaris 8.

I used the Tester to try some request.
It works well, for DescribeFeatureType and GetFeature request(GetCapabilities seems to have some bug, but that's not the big problem)

But I can't get a Transaction working. I know it can work because the line " http://localhost:8080/geoserver/Transaction?operation=delete&typename=xxxxx&featureid=00001 " is a success.
As soon as i use xml encoded requests, it stops working.
Maybe i'm making a mistake in the xml shema ...
Here are two requests that should work but don't (i tried different schemas in order to find one which works ...):

1)
<?xml version="1.0" encoding='ISO-8859-1' ?>
<Transaction version="1.0.0" service="WFS" outputFormat="XMLSCHEMA">
  <wfs:Delete typename="Comm">
    <ogc:filter>
      <ogc:FeatureId fid="Comm.17117">
    </ogc:filter>
  </wfs:Delete>
</wfs:Transaction>

2)
<?xml version="1.0"?>
<wfs:Transaction version="1.0.0" service="WFS" xsi:schemaLocation="http://localhost:8080/geoserver/DescribeFeatureType?typename=comm&quot;&gt;
  <wfs:Insert>
    <Comm>
      <gid>1000</gid>
      <ID_BDCARTO>15</ID_BDCARTO>
      <NOM_COMM>Test</NOM_COMM>
      <INSEE_COMM>007</INSEE_COMM>
      <SATUT>Capital</SATUT>
      <X_COMMUNE>668000</X_COMMUNE>
      <Y_COMMUNE>1802360</Y_COMMUNE>
      <SUPERFICIE>5000</SUPERFICIE>
      <POPULATION>5000</POPULATION>
      <INSEE_CANT>14</INSEE_CANT>
      <INSEE_ARR>3</INSEE_ARR>
      <NOM_DEPT>AUDE</NOM_DEPT>
      <INSEE_DEPT>11</INSEE_DEPT>
      <NOM_REGION>LANGUEDOC-ROUSSILLON</NOM_REGION>
      <INSEE_REG>91</INSEE_REG>
      <the_geom>
        <gml:Polygon>
          <gml:outerBoundaryIs>
            <gml:LinearRing>
              <gml:coordinates>-100,50,-110,55</gml:coordinates>
            </gml:LinearRing>
          </gml:outerBoundaryIs>
        </gml:Polygon>
      </the_geom>
    </Commune>
  </wfs:Insert>
</wfs:Transaction>

Note that these two examples are not encoded the same way (see the two first lines of each) but anyway, it doesn't work

I always get a IOException because the result of the request is an HTTP error code 500 (Servlet exception)

Please help me !!!
I don't know what to do :confused:

Thanks a lot !

_________________________________________________________________
Hotmail : un compte GRATUIT qui vous suit partout et tout le temps ! http://g.msn.fr/FR1000/9493

Ok, so there are a few problems with your requests, but I suspect you may
have something initially set up wrong.

I always get a IOException because the result of the request is an HTTP
error code 500 (Servlet exception)

I'm having trouble reproducing this error exactly, but I've also made a
number of changes to my wfsTester. But I don't think you should be
getting HTTP error code 500 (Servlet exception)s. Do GetFeature and
DescribeFeature type work with XML on the wfsTester? Because it sounds
like you may not have the tester set to Post. I think you set
<isPost>true</isPost> before using an xml request. The wfsTester code is
a bit old, and could use some updating, but working on geoserver is
currently a higher priority.

If that does not fix anything, there are a few other problems, but
GeoServer _should_ be at least attempting to report those errors in
TransactionResponses, not getting servlet exceptions. Sorry for the lack
of guidance on transaction requests...I'll try to get some documentation
of some sample queries in the next release.

As for the problems with your queries:

1)
<?xml version="1.0" encoding='ISO-8859-1' ?>
<Transaction version="1.0.0" service="WFS" outputFormat="XMLSCHEMA">
  <wfs:Delete typename="Comm">
    <ogc:filter>
      <ogc:FeatureId fid="Comm.17117">
    </ogc:filter>
  </wfs:Delete>
</wfs:Transaction>

The first problem that will hit you (and unfortunately GeoServer gives
a rather cryptic message...I'll try to work on that), is that you are
not declaring namespaces for the wfs and ogc prefixes. In the
Transaction element you need an xmlns:wfs="http://www.opengis.net/wfs&quot;
and a xmlns:ogc="http://www.opengis.net/ogc&quot;\. Geoserver will actually
work if you don't declare the namespaces and don't use prefixes, but not
if you use prefixes _and_ don't declare what those prefixes represent.

The next two things that I see wrong are the termination of elements -
<Transaction> should be mirrored by </Transaction>, not
</wfs:Transaction>. Or else both should have the wfs prefix. And the
featureId line should be <ogc:FeatureId fid="Comm.17117"/>, with a slash
at the second to last character. The SAX parser will complain if you
don't properly close your xml.

The next problem is the cases - filter should be Filter, and typename
should be typeName. I suppose we could make geoserver a bit more
forgiving, but then those elements will not match the wfs spec exactly.
Perhaps we shall add a user configurable option for how forgiving the
server is to reading requests.

So the proper query should look something like this:
<?xml version="1.0" encoding='ISO-8859-1' ?>
<wfs:Transaction
    xmlns:wfs="http://www.opengis.net/wfs&quot;
    xmlns:ogc="http://www.opengis.net/ogc&quot;
    version="1.0.0" service="WFS" outputFormat="XMLSCHEMA">
   <wfs:Delete typeName="Comm">
     <ogc:Filter>
       <ogc:FeatureId fid="Comm.17117">
     </ogc:Filter>
   </wfs:Delete>
</wfs:Transaction>

2)
<?xml version="1.0"?>
<wfs:Transaction version="1.0.0" service="WFS"
xsi:schemaLocation="http://localhost:8080/geoserver/DescribeFeatureType?typename=comm&quot;&gt;
  <wfs:Insert>
    <Comm>
      <gid>1000</gid>

         ....

      <the_geom>
        <gml:Polygon>
          <gml:outerBoundaryIs>
            <gml:LinearRing>
              <gml:coordinates>-100,50,-110,55</gml:coordinates>
            </gml:LinearRing>
          </gml:outerBoundaryIs>
        </gml:Polygon>
      </the_geom>
    </Commune>
  </wfs:Insert>
</wfs:Transaction>

For this transaction I don't know what your schema looks like, so I can't
comment for sure on if the whole transaction is correct or not. But you
are again lacking the namespaces, and inserts won't work without the
namespace. You need the default namespace -
xmlns="htttp://yourserver.com/myns". The uri should be the one given back
to you by a DescribeFeatureType request as the targetNamespace. You will
also need the gml namespace, or else the GeoServer xml parser will not
pick up the correct gml. And if you're using the wfs prefix that should
be in there soon.

So the beginning of your transaction should be:

<?xml version="1.0"?>
<wfs:Transaction version="1.0.0" service="WFS"
   xmlns="http://yourserver.com/myns&quot; <!--(or whatever the targetNamespace
of Describe feature type is)-->
   xmlns:wfs="http://www.opengis.net/wfs&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;&gt;
   <wfs:Insert>
          ...

Geoserver will actually let you get by for now without the schemaLocation,
but it's a good idea to include it, as a future version of geoserver might
make use of it. Doing so could allow us create new tables with an insert,
something we can't do right now.

Let me know if this solves your problem, and we apologize for not having
better transaction examples on the website or in the wfsTester. If you
are still having issues I will attempt to figure out the wfsTester code
and replicate your problem exactly.

good luck,

  Chris