0

I am having difficulty understanding the topic when it comes to XML generated from GeoServer and how can we interact with it. I want to to implement WFS transaction service and updating my attributes via web browser.

enter image description here.

I have the snippet code from book title Mastering OpenLayers about WFST

        map.getLayers().item(1).getSource().on('change', function (evt) {
        if (this.getState() === 'ready') {
        map.getLayers().item(1).buildHeaders();
        var geoJSONSerializer = new ol.format.GeoJSON();
        var featString = geoJSONSerializer.writeFeatures(this.getFeatures());
        var request = new XMLHttpRequest();
        request.open('POST', 'http://127.0.0.1:8080/geoserver/wfs');
        request.send(featString);

        var WFSTSerializer = new ol.format.WFS();
        var featObject = WFSTSerializer.writeTransaction(this.getFeatures, 
        null, null, {
            featureType: 'admin_kel_batu',
            featureNS: 'http://sigweb_cafe',
            srsName: 'EPSG:4326'
        });
        var serializer = new XMLSerializer();
        var featString = serializer.serializeToString(featObject);
        var request = new XMLHttpRequest();
        request.open('POST', 'http://127.0.0.1:8080/geoserver/wfs');
        request.setRequestHeader('Content-Type', 'text/xml');
        request.send(featString);
        console.log(featString);
    }
});

But still I got error and I have no idea how to fix it. What am I doing wrong or what is missing?

this is the xml being sent :

<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"/>
  • 1
    It would be helpful if you could provide a more comprehensive code snippet. – Ulas Feb 19 at 8:18
  • please add the xml being sent and the error you receive, plus if possible what the log file says – Ian Turton Feb 19 at 8:48
  • @Ulas i had update my code – Yogi2296 Feb 21 at 20:41
  • @IanTurton i had added the xml. where can i find the log ?? – Yogi2296 Feb 21 at 20:46
  • the log is in the logs folder of your data directory, and there is nothing in your xml which may be why it is not working – Ian Turton Feb 22 at 8:14

Your Answer

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

Browse other questions tagged or ask your own question.