Hi all,
I have a project to do that will involve OpenLayers 3 and GeoServer with a WFS-T.
I’m not very comfortable with these technologies and I’m discovering them step by step.
I have to implement a way to edit features and save them to database.
I found many samples to make editions on client side with OpenLayers and send them with ol.format.WFS.writeTransaction(feature, null, null, options) and XMLSerializer.serializeToString().
I found explanations on these URL :
- http://boundlessgeo.com/2014/06/openlayers-editing-wfs-t/
- http://wordpress-dbauszus.rhcloud.com/wfs-t-with-openlayers-3-5/
But nothing is happening on server side (database save), and I would like to know what I’m missing.
My WFS layer on GeoServer is bind to an Oracle database.
In Services/WFS options, the service level is set to “Complete”, so WFS-T should be activated I guess ?
And now ? What I have to do else ?
Maybe this is about the JavaScript code (I try an autosave at each draw end) :
Draw.Polygon.on(‘drawend’, function (e) {
var feature = e.feature;
var wfs = new ol.format.WFS();
var options = {
srsName: “EPSG:2169”,
featureNS: “ANF”,
featureType: “PARC_BIODEM_SP”
};
var node = wfs.writeTransaction(feature, null, null, options);
var s = new XMLSerializer();
var payload = s.serializeToString(node);
$.ajax(‘http://localhost:8090/geoserver/ANF/ows’, {
type: ‘POST’,
dataType: ‘xml’,
processData: false,
contentType: ‘text/xml’,
data: payload
}).done(function (e) {
var wfs = new ol.format.WFS();
wfs.readTransactionResponse(e);
});
}); |
- |
In “featureNS”, I put namespace of my layers from GeoServer, is it correct ?
In “featureType”, I put the datatable name associated to the layer, is it correct ?
In the Ajax post, the URL is “{geoserver_root}{namespace}{OWS}”, is it correct ?
Samples and/or tutorials, and mostly good explanations will be greatly appreciated
Many thanks.
JCB