Geoserver WFS-T "Feature type 'Workspace:Layer' is not available" Error on update / d
I am using the following code for insert / update (changed from this source: http://wordpress-dbauszus.rhcloud.com/?p=71):
var formatWFS = new ol.format.WFS();
// GML Format zur Interaktion mit WFSvar formatGML = new ol.format.GML({ featureNS: 'http://my-address:8080/geoserver/web/myworkspace', featureType: 'MyWorkspace:MyLayer', srsName: myProjectionName});
var transactWFS = function(transactionType,feature) { var node; switch(transactionType) { case 'insert': node = formatWFS.writeTransaction([feature],null,null,formatGML); break; case 'update': node = formatWFS.writeTransaction(null,[feature],null,formatGML); break; case 'delete': node = formatWFS.writeTransaction(null,null,[feature],formatGML); break; } s = new XMLSerializer(); str = s.serializeToString(node);
// XMLHttpRequest var xhttp = new XMLHttpRequest(); var url = 'http://my-address:8080/geoserver/web/myworkspace/wfs'; xhttp.open('POST', url, true); //xhttp.setRequestHeader('crossDomain', true); xhttp.setRequestHeader('dataType', 'xml'); //xhttp.setRequestHeader('processData', false); xhttp.setRequestHeader('contentType', 'text/xml'); //xhttp.onreadystatechange = handler; xhttp.send(str); xhttp.onreadystatechange = function() { console.log("Request Response: " + xhttp.responseText); };}
The insert works like it should using this function:
// Button to add a Feature$("#btn_add").click(function(e){ e.preventDefault(); // create feature from draw feature var feature = drawSource.getFeatures()[0]; // set properties feature.setProperties({ NAME: $("#name").val(), AGE: $("#age").val(), GEOLOC: feature.getGeometry() }); // Insert feature transactWFS('insert', f);});
For update I am using this functions (taking values from text field like in the insert function and not changing the geometry):
// Button to change a Feature$("#btn_change").click(function(e){ e.preventDefault(); // get selected feature from map (selectedFeature) var feature = selectedFeature; feature.setProperties({ NAME: $("#name").val(), AGE: $("#age").val() }); var feature = createUpdateFeature(); // update feature transactWFS('update', f);});
The update function is throwing this exception
Feature type 'MyWorkspace:MyLayer' is not available:
The feature type is not changed so I do not know why the insert is working but the update is not.
أكثر...
I am using the following code for insert / update (changed from this source: http://wordpress-dbauszus.rhcloud.com/?p=71):
var formatWFS = new ol.format.WFS();
// GML Format zur Interaktion mit WFSvar formatGML = new ol.format.GML({ featureNS: 'http://my-address:8080/geoserver/web/myworkspace', featureType: 'MyWorkspace:MyLayer', srsName: myProjectionName});
var transactWFS = function(transactionType,feature) { var node; switch(transactionType) { case 'insert': node = formatWFS.writeTransaction([feature],null,null,formatGML); break; case 'update': node = formatWFS.writeTransaction(null,[feature],null,formatGML); break; case 'delete': node = formatWFS.writeTransaction(null,null,[feature],formatGML); break; } s = new XMLSerializer(); str = s.serializeToString(node);
// XMLHttpRequest var xhttp = new XMLHttpRequest(); var url = 'http://my-address:8080/geoserver/web/myworkspace/wfs'; xhttp.open('POST', url, true); //xhttp.setRequestHeader('crossDomain', true); xhttp.setRequestHeader('dataType', 'xml'); //xhttp.setRequestHeader('processData', false); xhttp.setRequestHeader('contentType', 'text/xml'); //xhttp.onreadystatechange = handler; xhttp.send(str); xhttp.onreadystatechange = function() { console.log("Request Response: " + xhttp.responseText); };}
The insert works like it should using this function:
// Button to add a Feature$("#btn_add").click(function(e){ e.preventDefault(); // create feature from draw feature var feature = drawSource.getFeatures()[0]; // set properties feature.setProperties({ NAME: $("#name").val(), AGE: $("#age").val(), GEOLOC: feature.getGeometry() }); // Insert feature transactWFS('insert', f);});
For update I am using this functions (taking values from text field like in the insert function and not changing the geometry):
// Button to change a Feature$("#btn_change").click(function(e){ e.preventDefault(); // get selected feature from map (selectedFeature) var feature = selectedFeature; feature.setProperties({ NAME: $("#name").val(), AGE: $("#age").val() }); var feature = createUpdateFeature(); // update feature transactWFS('update', f);});
The update function is throwing this exception
Feature type 'MyWorkspace:MyLayer' is not available:
The feature type is not changed so I do not know why the insert is working but the update is not.
أكثر...