I have a function that manage WFS-T Transaction between a web application client (based on OpenLayers 6) and a GeoServer instance.
import axios from "axios";
import { WFS } from "ol/format";
import { FeatureCollection } from "geojson";
import { WriteTransactionOptions } from "ol/format/WFS";
import Feature from "ol/Feature";
const WFSTransaction = (mode: TransactionMode, featuresArray: Feature[]) => {
const formatWFS = new WFS();
const xs = new XMLSerializer();
const options: WriteTransactionOptions = {
featureNS: "myDomain",
featureType: "mylayer",
srsName: "EPSG:4326",
featurePrefix: "",
nativeElements: [],
};
let node;
switch (mode) {
case "insert":
node = formatWFS.writeTransaction(featuresArray, [], [], options);
break;
case "update":
node = formatWFS.writeTransaction([], featuresArray, [], options);
break;
case "delete":
node = formatWFS.writeTransaction([], [], featuresArray, options);
break;
default:
console.log(
"passed transaction mode did not match any of the supported transactions mode"
);
break;
}
if (node) {
const wfsNode = xs.serializeToString(node);
return axios.post(
`${this._domain}/ows?service=WFS&typeName=${this.fType}`,
wfsNode,
{
headers: { "Content-Type": "text/xml" },
}
);
}
};
Everything is working fine.
BUT if I send a feature with some attributes that does not match my table schema in the geoserver store (which is basically a PostgreSQL instance), I got an error message :
<?xml version="1.0" encoding="UTF-8"?><ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://meitarimdb:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd">
<ows:Exception exceptionCode="InvalidParameterValue">
<ows:ExceptionText>No such property: editable</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>
Now the thing is that the property "editable" (that you can see in the error message) is something that I set on purpose and dynamically to the OpenLayers Feature on the flight.
myFeature.set("editable", true);
Well if I unset
this property that I added before sending the transaction, my feature gets updated ...
But this not ideal because for each property that I add dynamically for logical purpose of the application, I have to unset it before sending the transaction. And there is a bunch of them...
So I wonder if there is any options to make the GeoServer more flexible with the properties that I send and simply ignore if a property is not present in the schema, and update those that are presents on the schemas
I did not found in the documentation.