[Geoserver-devel] A little confused about WFS insert on trunk

Hi,
I'm not able to make my WFS insert work on trunk against the
versioned data store, whilst the same request against tasmania roads works fine.

So, I'm posting some hints hoping someone is able to get something out of them.
This is the tasmania request, that works

<wfs:Transaction service="WFS" version="1.0.0"
   xmlns:wfs="http://www.opengis.net/wfs&quot;
   xmlns:topp="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd http://www.openplans.org/topp http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:tasmania_roads&quot;&gt;
   <wfs:Insert>
     <topp:road>
       <topp:id>600</topp:id>
       <topp:geom>
         <gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
               <gml:coordinates decimal="." cs="," ts=" ">5 5 10 10 15 5</gml:coordinates>
         </gml:LineString>
       </topp:geom>
       <topp:name>curva</topp:name>
     </topp:road>
   </wfs:Insert>
</wfs:Transaction>

Oh hum, first thing suprising me is that the schema location for topp:roads in this request is wrong. There is nothing answering at
http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:road
The request is simply wrong, unless we had a specific shortcut for DescribeFeatureType.
The proper request is:
http://localhost:8080/geoserver/wfs?request=DescribeFeatureType&typename=topp:tasmania_roads&version=1.0.0
but pasting there the proper request simply breaks the xml parser, that complains the xml is malformed:

org.xmlpull.v1.XmlPullParserException: entity reference name can not contain character =' (position: START_DOCUMENT seen ...localhost:8080/geoserver/wfs?request=DescribeFeatureType&typename=... @13:210)

Anyways, if I try to insert with my feature type, it breaks at xml feature parsing level.
Here is my the describe feature type output for "topp:road":

<?xml version="1.0" encoding="UTF-8"?><xs:schema targetNamespace="http://www.openplans.org/topp&quot; xmlns:topp="http://www.openplans.org/topp&quot; xmlns:gml="http://www.opengis.net/gml&quot; xmlns:xs="http://www.w3.org/2001/XMLSchema&quot; elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0"><xs:import namespace="http://www.opengis.net/gml&quot; schemaLocation="http://localhost:8080/geoserver/schemas/gml/2.1.2/feature.xsd&quot;/&gt;&lt;xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema&quot; name="road_Type">
  <xs:complexContent>
  <xs:extension base="gml:AbstractFeatureType">
  <xs:sequence>
  <xs:element name="id" minOccurs="0" nillable="true" type="xs:int"/>
  <xs:element name="geom" minOccurs="0" nillable="true" type="gml:LineStringPropertyType"/>
  <xs:element name="name" minOccurs="0" nillable="true">
  <xs:simpleType>
  <xs:restriction base="xs:string">

  <xs:maxLength value="2147483647"/>
  </xs:restriction>
  </xs:simpleType>
  </xs:element>
  </xs:sequence>
  </xs:extension>
  </xs:complexContent>
  </xs:complexType>
  <xs:element name='road' type='topp:road_Type' substitutionGroup='gml:_Feature'/></xs:schema>

And here is my request:

<wfs:Transaction service="WFS" version="1.0.0"
   xmlns:wfs="http://www.opengis.net/wfs&quot;
   xmlns:topp="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd http://www.openplans.org/topp http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:road&quot;&gt;
   <wfs:Insert>
     <topp:road>
       <topp:id>600</topp:id>
       <topp:geom>
         <gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
               <gml:coordinates decimal="." cs="," ts=" ">5 5 10 10 15 5</gml:coordinates>
         </gml:LineString>
       </topp:geom>
       <topp:name>curva</topp:name>
     </topp:road>
   </wfs:Insert>
</wfs:Transaction>

much alike tasmania_roads, seems to respect the schema, but all I get is:

org.xml.sax.SAXException: Handler for topp:name could not be found.
  at org.geotools.xml.impl.ParserHandler.startElement(ParserHandler.java:380)
  at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
  at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
  at org.geotools.xml.Parser.parse(Parser.java:184)
  at org.geotools.xml.Parser.parse(Parser.java:163)
  at org.geoserver.wfs.xml.v1_0_0.WfsXmlReader.read(WfsXmlReader.java:28)
  at org.geoserver.ows.Dispatcher.parseRequestXML(Dispatcher.java:955)
  at org.geoserver.ows.Dispatcher.dispatch(Dispatcher.java:365)

Oh hum... why is that??? The schema specifies element names are qualified, so topp:name should be ok.
Having that http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:road
link working would be nice too, since it would allow the request to be
put into a xml editor with validation and auto-completion too.

Cheers
Andrea

Andrea Aime wrote:

Hi,
I'm not able to make my WFS insert work on trunk against the
versioned data store, whilst the same request against tasmania roads
works fine.

So, I'm posting some hints hoping someone is able to get something out
of them.
This is the tasmania request, that works

<wfs:Transaction service="WFS" version="1.0.0"
   xmlns:wfs="http://www.opengis.net/wfs&quot;
   xmlns:topp="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd
http://www.openplans.org/topp
http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:tasmania_roads&quot;&gt;
   <wfs:Insert>
     <topp:road>
       <topp:id>600</topp:id>
       <topp:geom>
         <gml:LineString
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
               <gml:coordinates decimal="." cs="," ts=" ">5 5 10 10 15
5</gml:coordinates>
         </gml:LineString>
       </topp:geom>
       <topp:name>curva</topp:name>
     </topp:road>
   </wfs:Insert>
</wfs:Transaction>

Hmm, yeah this is a problem with the new dispatcher. Although I thought
I fixed this... maybe not. Oh I think there is a jira open for this. I
may have to repoen it.

Oh hum, first thing suprising me is that the schema location for
topp:roads in this request is wrong. There is nothing answering at
http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:road
The request is simply wrong, unless we had a specific shortcut for
DescribeFeatureType.
The proper request is:
http://localhost:8080/geoserver/wfs?request=DescribeFeatureType&typename=topp:tasmania_roads&version=1.0.0
but pasting there the proper request simply breaks the xml parser, that
complains the xml is malformed:

org.xmlpull.v1.XmlPullParserException: entity reference name can not
contain character =' (position: START_DOCUMENT seen
...localhost:8080/geoserver/wfs?request=DescribeFeatureType&typename=...
@13:210)

Anyways, if I try to insert with my feature type, it breaks at xml
feature parsing level.
Here is my the describe feature type output for "topp:road":

<?xml version="1.0" encoding="UTF-8"?><xs:schema
targetNamespace="http://www.openplans.org/topp&quot;
xmlns:topp="http://www.openplans.org/topp&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
xmlns:xs="http://www.w3.org/2001/XMLSchema&quot;
elementFormDefault="qualified" attributeFormDefault="unqualified"
version="1.0"><xs:import namespace="http://www.opengis.net/gml&quot;
schemaLocation="http://localhost:8080/geoserver/schemas/gml/2.1.2/feature.xsd&quot;/&gt;&lt;xs:complexType
xmlns:xs="http://www.w3.org/2001/XMLSchema&quot; name="road_Type">
  <xs:complexContent>
  <xs:extension base="gml:AbstractFeatureType">
  <xs:sequence>
  <xs:element name="id" minOccurs="0" nillable="true" type="xs:int"/>
  <xs:element name="geom" minOccurs="0" nillable="true"
type="gml:LineStringPropertyType"/>
  <xs:element name="name" minOccurs="0" nillable="true">
  <xs:simpleType>
  <xs:restriction base="xs:string">

  <xs:maxLength value="2147483647"/>
  </xs:restriction>
  </xs:simpleType>
  </xs:element>
  </xs:sequence>
  </xs:extension>
  </xs:complexContent>
  </xs:complexType>
  <xs:element name='road' type='topp:road_Type'
substitutionGroup='gml:_Feature'/></xs:schema>

And here is my request:

<wfs:Transaction service="WFS" version="1.0.0"
   xmlns:wfs="http://www.opengis.net/wfs&quot;
   xmlns:topp="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd
http://www.openplans.org/topp
http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:road&quot;&gt;
   <wfs:Insert>
     <topp:road>
       <topp:id>600</topp:id>
       <topp:geom>
         <gml:LineString
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
               <gml:coordinates decimal="." cs="," ts=" ">5 5 10 10 15
5</gml:coordinates>
         </gml:LineString>
       </topp:geom>
       <topp:name>curva</topp:name>
     </topp:road>
   </wfs:Insert>
</wfs:Transaction>

There are some things wrong with your request:

1. topp:road -> topp:tasmania_roads
2. topp:geom -> topp:the_geom
3. the geometry is specified as a LineString, it needs to be a
MultiLineString
4. topp:name -> gml:name and needs to be the first attribute ( ie.
before topp:the_geom )
5. There is no attribute topp:id defined by the schema, so i don't
believe it should be there.

*3 might be a problem with the parser, i need to look into that.

So... the following should work:

<wfs:Transaction service="WFS" version="1.0.0"
   xmlns:wfs="http://www.opengis.net/wfs&quot;
   xmlns:topp="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd
http://www.openplans.org/topp
http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:tasmania_roads&quot;&gt;
   <wfs:Insert>
     <topp:tasmania_roads>
       <gml:name>curva</gml:name>
       <topp:the_geom>
<gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
          <gml:lineStringMember>
         <gml:LineString
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
               <gml:coordinates decimal="." cs="," ts=" ">5 5 10 10 15
5</gml:coordinates>
         </gml:LineString>
   </gml:lineStringMember>
        </gml:MultiLineString>
       </topp:the_geom>
      </topp:tasmania_roads>
   </wfs:Insert>
</wfs:Transaction>

The request does not however work when the version is 1.1, I am looking
into that.

-Justin

-------------------------------------------------------------------------
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
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

!DSPAM:1004,45e72178145694820651628!

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org

Justin Deoliveira ha scritto:

Andrea Aime wrote:

topp:road is another feature type, that is backed by the versioned
datastore. And it has the following schema:

Here is my the describe feature type output for "topp:road":

<?xml version="1.0" encoding="UTF-8"?><xs:schema targetNamespace="http://www.openplans.org/topp&quot; xmlns:topp="http://www.openplans.org/topp&quot; xmlns:gml="http://www.opengis.net/gml&quot; xmlns:xs="http://www.w3.org/2001/XMLSchema&quot; elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0"><xs:import namespace="http://www.opengis.net/gml&quot; schemaLocation="http://localhost:8080/geoserver/schemas/gml/2.1.2/feature.xsd&quot;/&gt;&lt;xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema&quot; name="road_Type">
  <xs:complexContent>
  <xs:extension base="gml:AbstractFeatureType">
  <xs:sequence>
  <xs:element name="id" minOccurs="0" nillable="true" type="xs:int"/>
  <xs:element name="geom" minOccurs="0" nillable="true" type="gml:LineStringPropertyType"/>
  <xs:element name="name" minOccurs="0" nillable="true">
  <xs:simpleType>
  <xs:restriction base="xs:string">

  <xs:maxLength value="2147483647"/>
  </xs:restriction>
  </xs:simpleType>
  </xs:element>
  </xs:sequence>
  </xs:extension>
  </xs:complexContent>
  </xs:complexType>
  <xs:element name='road' type='topp:road_Type' substitutionGroup='gml:_Feature'/></xs:schema>

And here is my request:

<wfs:Transaction service="WFS" version="1.0.0"
   xmlns:wfs="http://www.opengis.net/wfs&quot;
   xmlns:topp="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd http://www.openplans.org/topp http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:road&quot;&gt;
   <wfs:Insert>
     <topp:road>
       <topp:id>600</topp:id>
       <topp:geom>
         <gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
               <gml:coordinates decimal="." cs="," ts=" ">5 5 10 10 15 5</gml:coordinates>
         </gml:LineString>
       </topp:geom>
       <topp:name>curva</topp:name>
     </topp:road>
   </wfs:Insert>
</wfs:Transaction>

There are some things wrong with your request:

1. topp:road -> topp:tasmania_roads
2. topp:geom -> topp:the_geom
3. the geometry is specified as a LineString, it needs to be a
MultiLineString
4. topp:name -> gml:name and needs to be the first attribute ( ie.
before topp:the_geom )
5. There is no attribute topp:id defined by the schema, so i don't
believe it should be there.

??? I want to insert a feature into topp:road.
I included the topp:tasmania_roads samples because they do work,
and tried to compare and contrast them with topp:road because that
one does _not_ work.

Can you re-read my first mail?
Cheers
Andrea

Oops, my apologies Andrea, I got a little confused there :).

Since the name attribute is already defined on gml:AbstractFeatureType,
try changing "topp:name" to "gml:name". I think you have hit on an issue
with our feature model. You have to attributes called "name" in two
different namespaces. Which one actually gets respected might be a toss
up, although I dont think the parser should be choking on this. I can
look into it.

For now try changing the namespace and let me know if that works.

-Justin

Andrea Aime wrote:

Justin Deoliveira ha scritto:

Andrea Aime wrote:

topp:road is another feature type, that is backed by the versioned
datastore. And it has the following schema:

Here is my the describe feature type output for "topp:road":

<?xml version="1.0" encoding="UTF-8"?><xs:schema
targetNamespace="http://www.openplans.org/topp&quot;
xmlns:topp="http://www.openplans.org/topp&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
xmlns:xs="http://www.w3.org/2001/XMLSchema&quot;
elementFormDefault="qualified" attributeFormDefault="unqualified"
version="1.0"><xs:import namespace="http://www.opengis.net/gml&quot;
schemaLocation="http://localhost:8080/geoserver/schemas/gml/2.1.2/feature.xsd&quot;/&gt;&lt;xs:complexType
xmlns:xs="http://www.w3.org/2001/XMLSchema&quot; name="road_Type">
  <xs:complexContent>
  <xs:extension base="gml:AbstractFeatureType">
  <xs:sequence>
  <xs:element name="id" minOccurs="0" nillable="true" type="xs:int"/>
  <xs:element name="geom" minOccurs="0" nillable="true"
type="gml:LineStringPropertyType"/>
  <xs:element name="name" minOccurs="0" nillable="true">
  <xs:simpleType>
  <xs:restriction base="xs:string">

  <xs:maxLength value="2147483647"/>
  </xs:restriction>
  </xs:simpleType>
  </xs:element>
  </xs:sequence>
  </xs:extension>
  </xs:complexContent>
  </xs:complexType>
  <xs:element name='road' type='topp:road_Type'
substitutionGroup='gml:_Feature'/></xs:schema>

And here is my request:

<wfs:Transaction service="WFS" version="1.0.0"
   xmlns:wfs="http://www.opengis.net/wfs&quot;
   xmlns:topp="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd
http://www.openplans.org/topp
http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:road&quot;&gt;

   <wfs:Insert>
     <topp:road>
       <topp:id>600</topp:id>
       <topp:geom>
         <gml:LineString
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
               <gml:coordinates decimal="." cs="," ts=" ">5 5 10 10
15 5</gml:coordinates>
         </gml:LineString>
       </topp:geom>
       <topp:name>curva</topp:name>
     </topp:road>
   </wfs:Insert>
</wfs:Transaction>

There are some things wrong with your request:

1. topp:road -> topp:tasmania_roads
2. topp:geom -> topp:the_geom
3. the geometry is specified as a LineString, it needs to be a
MultiLineString
4. topp:name -> gml:name and needs to be the first attribute ( ie.
before topp:the_geom )
5. There is no attribute topp:id defined by the schema, so i don't
believe it should be there.

??? I want to insert a feature into topp:road.
I included the topp:tasmania_roads samples because they do work,
and tried to compare and contrast them with topp:road because that
one does _not_ work.

Can you re-read my first mail?
Cheers
Andrea

!DSPAM:1004,45e7332a163051365099012!

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org

Justin Deoliveira ha scritto:

Oops, my apologies Andrea, I got a little confused there :).

Since the name attribute is already defined on gml:AbstractFeatureType,
try changing "topp:name" to "gml:name". I think you have hit on an issue
with our feature model. You have to attributes called "name" in two
different namespaces. Which one actually gets respected might be a toss
up, although I dont think the parser should be choking on this. I can
look into it.

For now try changing the namespace and let me know if that works.

With gml:name it worked.... oh, I don't know if this ability I have to
find issues is a bless or a curse.
I spend probably 2 hours on this between uDig not working and trying simple requests, don't know if laugh or bang my head on the table.

Well, ok, I'll use another feature type.
Btw, that "road" feature type is one of our datastore test types,
have a look in the postgis tests.

Cheers
Andrea