I'm using OpenLayers-3. I have a wfs layer. I want to sync this layer with my server as follow(I use geoserver 2.7-SNAPSHOT and my datastore's type is shapefile):
var opt = {
featureType: "Calk:Point",
featureNS: "http://itsme.calk.org",
srsName: "EPSG:4326"
}
var s = new XMLSerializer();
var url = "http://localhost:8080/geoserver/wfs";
var node = wfs.writeTransaction(InsertFeaturesArr, updateFeaturesArr, deleteFeaturesArr, opt);
Ext.Ajax.request({
url: 'proxy.cgi?url=' + encodeURIComponent(url),
method: 'POST',
xmlData: s.serializeToString(node),
headers: {
'Content-Type': 'text/xml'
},
success: function(response_) {
response = response_;
}
});
It create a payload request as follow:
<Transaction
xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<Insert>
<Point xmlns="http://itsme.calk.ir">
<the_geom>
<Point xmlns="http://www.opengis.net/gml">
<pos>44.53857421875 25.492868271257123</pos>
</Point>
</the_geom>
...
<NAME>asdf</NAME>
</Point>
</Insert>
<Update typeName="Calk:Point" xmlns:Calk="http://itsme.calk.ir">
<Property>
<Name>the_geom</Name>
<Value>
<Point xmlns="http://www.opengis.net/gml">
<pos>29.614517211914062 52.532684326171875</pos>
</Point>
</Value>
</Property>
...
<Filter xmlns="http://www.opengis.net/ogc">
<FeatureId fid="Point.21"/>
</Filter>
</Update>
<Delete typeName="Calk:Point" xmlns:Calk="http://itsme.calk.ir">
<Filter xmlns="http://www.opengis.net/ogc">
<FeatureId fid="Point.24"/>
</Filter>
</Delete>
</Transaction>
It doesn't work properly. Geoserver's response is as follow:
<?xml version="1.0" encoding="UTF-8"?>
<wfs:TransactionResponse
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:Calk="http://itsme.calk.ir" xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gml="http://www.opengis.net/gml" xmlns:opengeo="http://opengeo.org" xmlns:usa="http://census.gov"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0"
xsi:schemaLocation="http://www.opengis.net/wfs http://localhost:8080/geoserver/schemas/wfs/1.1.0/wfs.xsd">
<wfs:TransactionSummary>
<wfs:totalInserted>1</wfs:totalInserted>
<wfs:totalUpdated>2</wfs:totalUpdated>
<wfs:totalDeleted>3</wfs:totalDeleted>
</wfs:TransactionSummary>
<wfs:TransactionResults/>
<wfs:InsertResults>
<wfs:Feature>
<ogc:FeatureId fid="new0"/>
</wfs:Feature>
</wfs:InsertResults>
</wfs:TransactionResponse>
In this case, it must add a feature with NAME
property: asdf
(it does not add new feature), and update a feature(It does not update any feature), and delete a feature(It do this correctly). But when I create 3 request and as follow, It doesn't delete the feature some times:
var insertNode = wfs.writeTransaction(InsertFeaturesArr, [], [], opt);
Ext.Ajax.request({
...
xmlData: s.serializeToString(insertNode),
...
});
var updateNode = wfs.writeTransaction([], updateFeaturesArr [], opt);
Ext.Ajax.request({
...
xmlData: s.serializeToString(updateNode),
...
});
var deleteNode = wfs.writeTransaction([], [], deleteFeaturesArr, opt);
Ext.Ajax.request({
...
xmlData: s.serializeToString(deleteNode),
...
});
Where is the problem?
I tested this code with geoserver 2.8 t0o and it does not correctly too.