[TinyOWS-users] Problem inserting new features

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Sat Dec 3 07:42:36 EST 2011


Yes, order of attributes does matter in WFS. Here is a part of a FeatureType schema that comes with DescribeFeatureType request

<xs:complexType name="osm_pointType">
<xs:complexContent><xs:extension base="gml:AbstractFeatureType">
<xs:element name="osm_id" type="int" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="note" type="string" nillable="true" minOccurs="0" maxOccurs="1"/>

List of properities is defined to be "xs:sequence" which means that they must appear in correct order if they are used in the requests which contain XML. The only reliable way for knowing the correct order is to make the client to do DescribeFeatureType and read it from the service.

GET requests without any XML do not care about the propertyname order and both following requests work.,6780800,436400,6924000&propertyname=sahko,the_geom&maxfeatures=1,6780800,436400,6924000&propertyname=the_geom,sahko&maxfeatures=1

However, if the latter is send as http POST it will probably lead to an error because "the_geom" should come after "sahko".

-Jukka Rahkonen-

Nicolás Ardissono wrote:

I had the same problem, and you have two options to solve it. Because is a field order problem.
Check with pgadmin how your fields are orderer, you have first name and then the_geom, so tinyows doesn't except anything after the_geom. What you have to do is delete the name field and create it again so it will be after the_geom, with that it works for me.

Or you can try this script, but not always work:

 * @requires OpenLayers/Strategy.js

 * Allow to force the ordering of attributes before saving
 * @class
OpenLayers.Strategy.SaveAttrOrder =

   * Order of attributes to save.
   * Only the attributes listed here will be saved!
   * @type {Array.<string>}
  order: [],

   * Strategy to communicate with for save operation
   * @type {OpenLayers.Strategy.Save}
  saveStrategy: null,

   * APIMethod: activate
   * Activate the strategy.  Register any listeners, do appropriate setup.
   * Returns:
   * {Boolean} The strategy was successfully activated.
  activate: function() {
    var activated = OpenLayers.Strategy.prototype.activate.call(this);
    if (activated) {
          start: this.beforeSave,
          scope: this
    return activated;

   * APIMethod: deactivate
   * Deactivate the strategy.  Unregister any listeners, do appropriate
   *     tear-down.
   * Returns:
   * {Boolean} The strategy was successfully deactivated.
  deactivate: function() {
    var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);
    if(deactivated) {
          start: this.beforeSave,
          scope: this
    return deactivated;

  beforeSave: function(event) {
    var features = event.features;
    features.forEach(dojo.hitch(this, 'reorderFeature'));

  reorderFeature: function(feature) {
    var obj = {};
        function(attr) {
          if (feature.attributes.hasOwnProperty(attr)) {
            obj[attr] = feature.attributes[attr];
    feature.attributes = obj;

Hope this help

De: Jessica Lapointe <jlapointe at mapgears.com>
Para: tinyows-users at lists.maptools.org
Enviado: viernes, 2 de diciembre de 2011 16:41
Asunto: [TinyOWS-users] Problem inserting new features

I'm having trouble in inserting new features in my db. In fact I have
the same problem as described in there:
I use openlayers 2.11 and tinyows trunk revision 615.

I'm able to update and delete data with no problem. If I insert simple
features containing only geometry it also works. But if my new feature
has data, my xml response in firebug will be "XML request isn't
valid". Tinyows' log says :

[Fri Dec  2 14:30:11 2011] [ERROR] Element '{}name':
This element is not expected.

[Fri Dec  2 14:30:11 2011] [ERROR] XML request isn't valid

The xml sent to tinyows is the following:

<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs
<feature:popplace xmlns:feature="">
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:coordinates decimal="." cs="," ts="

Any help would be appreciated.
TinyOWS-users mailing list
TinyOWS-users at lists.maptools.org<mailto:TinyOWS-users at lists.maptools.org>

More information about the TinyOWS-users mailing list