Yeah - I've had this problem too.<div><br></div><div>Reordering the attribute fields in postgis has thus far been the only reliable way of ensuring that this does not occur.</div><div>( I could never get that OpenLayers strategy to work for my use-case, but so it goes).</div>
<div><br></div><div>Regrettably, postgres does<a href="http://wiki.postgresql.org/wiki/Alter_column_position"> not support column re-ordering</a> , so the only way is to do it via dropping/recreating columns or tables.</div>
<div><br></div><div>Kind regards,</div><div>Gissur<br><br><div class="gmail_quote">On Sat, Dec 3, 2011 at 12:42 PM, Rahkonen Jukka <span dir="ltr"><<a href="mailto:Jukka.Rahkonen@mmmtike.fi">Jukka.Rahkonen@mmmtike.fi</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
Yes, order of attributes does matter in WFS. Here is a part of a FeatureType schema that comes with DescribeFeatureType request<br>
<br>
<xs:complexType name="osm_pointType"><br>
<xs:complexContent><xs:extension base="gml:AbstractFeatureType"><br>
<xs:sequence><br>
<xs:element name="osm_id" type="int" nillable="true" minOccurs="0" maxOccurs="1"/><br>
<xs:element name="note" type="string" nillable="true" minOccurs="0" maxOccurs="1"/><br>
...<br>
<br>
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.<br>
<br>
GET requests without any XML do not care about the propertyname order and both following requests work.<br>
<br>
<a href="http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=sahko,the_geom&maxfeatures=1" target="_blank">http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=sahko,the_geom&maxfeatures=1</a><br>
<a href="http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=the_geom,sahko&maxfeatures=1" target="_blank">http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=the_geom,sahko&maxfeatures=1</a><br>
<br>
However, if the latter is send as http POST it will probably lead to an error because "the_geom" should come after "sahko".<br>
<br>
-Jukka Rahkonen-<br>
<br>
________________________________<br>
<div><div></div><div class="h5">Nicolás Ardissono wrote:<br>
<br>
I had the same problem, and you have two options to solve it. Because is a field order problem.<br>
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.<br>
<br>
Or you can try this script, but not always work:<br>
<br>
/**<br>
* @requires OpenLayers/Strategy.js<br>
*/<br>
<br>
/**<br>
* Allow to force the ordering of attributes before saving<br>
*<br>
* @class<br>
*/<br>
OpenLayers.Strategy.SaveAttrOrder =<br>
OpenLayers.Class(OpenLayers.Strategy,<br>
{<br>
<br>
/**<br>
* Order of attributes to save.<br>
*<br>
* Only the attributes listed here will be saved!<br>
*<br>
* @type {Array.<string>}<br>
*/<br>
order: [],<br>
<br>
/**<br>
* Strategy to communicate with for save operation<br>
*<br>
* @type {OpenLayers.Strategy.Save}<br>
*/<br>
saveStrategy: null,<br>
<br>
/**<br>
* APIMethod: activate<br>
* Activate the strategy. Register any listeners, do appropriate setup.<br>
*<br>
* Returns:<br>
* {Boolean} The strategy was successfully activated.<br>
*/<br>
activate: function() {<br>
var activated = OpenLayers.Strategy.prototype.activate.call(this);<br>
if (activated) {<br>
this.saveStrategy.events.on({<br>
start: this.beforeSave,<br>
scope: this<br>
});<br>
}<br>
return activated;<br>
},<br>
<br>
/**<br>
* APIMethod: deactivate<br>
* Deactivate the strategy. Unregister any listeners, do appropriate<br>
* tear-down.<br>
*<br>
* Returns:<br>
* {Boolean} The strategy was successfully deactivated.<br>
*/<br>
deactivate: function() {<br>
var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);<br>
if(deactivated) {<br>
this.saveStrategy.events.un({<br>
start: this.beforeSave,<br>
scope: this<br>
});<br>
}<br>
return deactivated;<br>
},<br>
<br>
beforeSave: function(event) {<br>
var features = event.features;<br>
features.forEach(dojo.hitch(this, 'reorderFeature'));<br>
},<br>
<br>
reorderFeature: function(feature) {<br>
var obj = {};<br>
this.order.forEach(<br>
function(attr) {<br>
if (feature.attributes.hasOwnProperty(attr)) {<br>
obj[attr] = feature.attributes[attr];<br>
}<br>
});<br>
feature.attributes = obj;<br>
}<br>
<br>
<br>
<br>
Hope this help<br>
<br>
________________________________<br>
De: Jessica Lapointe <<a href="mailto:jlapointe@mapgears.com">jlapointe@mapgears.com</a>><br>
Para: <a href="mailto:tinyows-users@lists.maptools.org">tinyows-users@lists.maptools.org</a><br>
Enviado: viernes, 2 de diciembre de 2011 16:41<br>
Asunto: [TinyOWS-users] Problem inserting new features<br>
<br>
Hello,<br>
I'm having trouble in inserting new features in my db. In fact I have<br>
the same problem as described in there:<br>
<a href="http://lists.maptools.org/pipermail/tinyows-users/2010-November/000230.html" target="_blank">http://lists.maptools.org/pipermail/tinyows-users/2010-November/000230.html</a><br>
I use openlayers 2.11 and tinyows trunk revision 615.<br>
<br>
I'm able to update and delete data with no problem. If I insert simple<br>
features containing only geometry it also works. But if my new feature<br>
has data, my xml response in firebug will be "XML request isn't<br>
valid". Tinyows' log says :<br>
<br>
[Fri Dec 2 14:30:11 2011] [ERROR] Element '{<a href="http://127.0.0.1/}name" target="_blank">http://127.0.0.1/}name</a>':<br>
This element is not expected.<br>
<br>
[Fri Dec 2 14:30:11 2011] [ERROR] XML request isn't valid<br>
<br>
The xml sent to tinyows is the following:<br>
<br>
<wfs:Transaction xmlns:wfs="<a href="http://www.opengis.net/wfs" target="_blank">http://www.opengis.net/wfs</a>" service="WFS"<br>
version="1.0.0" xsi:schemaLocation="<a href="http://www.opengis.net/wfs" target="_blank">http://www.opengis.net/wfs</a><br>
<a href="http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" target="_blank">http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd</a>"<br>
xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>"><br>
<wfs:Insert><br>
<feature:popplace xmlns:feature="<a href="http://127.0.0.1/" target="_blank">http://127.0.0.1/</a>"><br>
<feature:the_geom><br>
<gml:Point xmlns:gml="<a href="http://www.opengis.net/gml" target="_blank">http://www.opengis.net/gml</a>" srsName="EPSG:4326"><br>
<gml:coordinates decimal="." cs="," ts="<br>
">-45.925780534744,-11.97656750679</gml:coordinates><br>
</gml:Point><br>
</feature:the_geom><br>
<feature:name>test</feature:name><br>
</feature:popplace><br>
</wfs:Insert><br>
</wfs:Transaction><br>
<br>
Any help would be appreciated.<br>
_______________________________________________<br>
TinyOWS-users mailing list<br>
</div></div><a href="mailto:TinyOWS-users@lists.maptools.org">TinyOWS-users@lists.maptools.org</a><mailto:<a href="mailto:TinyOWS-users@lists.maptools.org">TinyOWS-users@lists.maptools.org</a>><br>
<a href="http://lists.maptools.org/mailman/listinfo/tinyows-users" target="_blank">http://lists.maptools.org/mailman/listinfo/tinyows-users</a><br>
<div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
TinyOWS-users mailing list<br>
<a href="mailto:TinyOWS-users@lists.maptools.org">TinyOWS-users@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/tinyows-users" target="_blank">http://lists.maptools.org/mailman/listinfo/tinyows-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Gissur Þórhallsson<br><br>Loftmyndir ehf.<br>Laugavegur 13<br>IS 101 Reykjavík - Iceland<br>sími (tel): (+354) 540 2500<br>tölvupóstur (email): <a href="mailto:gissur@loftmyndir.is">gissur@loftmyndir.is</a><br>
</div>