I am editing features on a map using Openlayers 3 and Geoserver 2.8 linked to a postgresql Database. for adding features there is no problem but when it comes to update features I get a wrong xml code when I run writeTransaction, here is my code :

var wfst=new ol.format.WFS({
            featureNS: "myNameSpace",
            featureType: "myLayer"
        var node = wfst.writeTransaction(null, [clone], null, {
            featureNS: "myNameSpace",
            featureType: "myLayer"
        alert((new XMLSerializer()).serializeToString(node));

The xml generated is :

<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Update typeName="feature:myLayer" xmlns:feature="myNameSpace">
<Polygon xmlns="http://www.opengis.net/gml"><exterior><LinearRing><posList>-7.741584777832031 33.52100372314453 -7.789649963378906 33.498687744140625 -7.758750915527344 33.45954895019531 -7.70416259765625 33.48186492919922 -7.741584777832031 33.52100372314453</posList></LinearRing></exterior>
<Filter xmlns="http://www.opengis.net/ogc">
<FeatureId fid="164"/></Filter></Update>

the problem is here typeName="feature:myLayer" in the Update line of the xml, once I change feature to myNameSpace the request works fine.

and if I leave it like that I get a java.lang.NullPointerException error.

What am I missing here?


I figured out a work around this error, it's not exactly what I hoped for but it gets the job done. So all I have to do is to modify the XML code for the update transaction in Javascript like this:

var str=new XMLSerializer().serializeToString(node);
var data=str.replace("feature:myLayer","myNameSpace:myLayer");

and then send data with an AJAX call to save the modification

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.