I was able to successfully create a Wfs_T app using the tutorial from https://medium.com/@goldrydigital/wfs-t-with-openlayers-3-16-6fb6a820ac58. I then decided to use this code to edit a file I'd made by creating a shapefile in QGIS, uploading into PostGIS, and then bringing it into GeoServer. To do this, all I did was change the code from
$.ajax('http://localhost:8080/geoserver/his_workspace/ows?', {
type: 'GET',
data: {
service: 'WFS',
version: '1.1.0',
request: 'GetFeature',
typename: 'his_layer_name',
srsname: 'EPSG:3857',
bbox: extent.join(',') + ',EPSG:3857'
}
})
var formatGML = new ol.format.GML({
featureNS: 'his_workspace',
featureType: 'his_layer_name',
srsName: 'EPSG:3857'
});
to
$.ajax('http://localhost:8080/geoserver/my_workspace/ows?', {
type: 'GET',
data: {
service: 'WFS',
version: '1.1.0',
request: 'GetFeature',
typename: 'my_layer_name',
srsname: 'EPSG:3857',
bbox: extent.join(',') + ',EPSG:3857'
}
})
var formatGML = new ol.format.GML({
featureNS: 'my_workspace',
featureType: 'my_layer_name',
srsName: 'EPSG:3857'
});
And I also changed
$.ajax('http://localhost:8080/geoserver/his_workspace/ows', {
type: 'POST',
dataType: 'xml',
processData: false,
contentType: 'text/xml',
data: payload
}).done(function() {
sourceWFS.clear();
});
to
$.ajax('http://localhost:8080/geoserver/my_workspace/ows', {
type: 'POST',
dataType: 'xml',
processData: false,
contentType: 'text/xml',
data: payload
}).done(function() {
sourceWFS.clear();
});
And Geoserver sends me the message:
org.geoserver.wfs.WFSException: No such feature type my_workspace:my_layer_name.
My describe feature type result is this:
<xsd:schema xmlns:my_workspace="my_workspace" xmlns:gml="http://www.opengis.net/gml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="www.my_workspace.com">
<xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>
<xsd:complexType name="my_layer_nameType">
<xsd: complexContent>
<xsd: extension base="gml:AbstractFeatureType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="id" nillable="false" type="xsd:long"/>
<xsd:element maxOccurs="1" minOccurs="1" name="geom" nillable="true" type="gml:PointPropertyType"/>
</xsd:sequence>
</xsd: extension>
</xsd: complexContent>
</xsd:complexType>
<xsd:element name="my_layer_name" substitutionGroup="gml:_Feature" type="my_workspace:my_layer_nameType"/>
</xsd:schema>
My workspace, data store, and namespace all have the same name. The constraints and other settings that the tutorial mentions seem to be the same for my file. I tried changing the namespace to a URI and I still get the error message. I do wonder if it's because the geometry is in a point(geometry) type while in the tutorial it's simply in a geometry type.
Edit: here is the XML: Raw XML request: <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><my_layer_name xmlns="my_workspace"><geometry><Point xmlns="http://www.opengis.net/gml" srsName="EPSG:3857"><pos srsDimension="2">-724011.5319171895 7284143.047464156</pos></Point></geometry></my_layer_name></Insert></Transaction>
Does anyone know why this isn't going through?