0

I'm trying to create wfs-t service I have used the ol.format.WFS#writeTransaction method and serialize the WFS-t XML but my jslint always preview error at the GML format options. Is it possible that I am initializing the ol.format.WFS object incorrectly?

Or maybe I am passing the wrong options to the writeTransaction method? Or maybe it's a bug in OpenLayers4? this detail of my wfs-t service using angular http service:

private _transactWFS(feature: any, operation: any): any {

    let payload;

    try {
        const formatWFS = new ol.format.WFS({});
        const formatGML = new ol.format.GML({
            featureNS: operation.featureNS,
            featureType: operation.featureType,
            srsName: operation.srsName
        });
        const xs = new XMLSerializer();
        let node: any = null;
        switch (operation.mode) {
            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;
        }

        payload = xs.serializeToString(node);
    } catch (error) {}

    return payload;
}

lint message:

 [ts]
Argument of type 'GML' is not assignable to parameter of type 'WFSWriteTransactionOptions'.
Property 'featureNS' is missing in type 'GML'.
Ian Turton
  • 10,018
  • 1
  • 28
  • 47
Teguh Santoso
  • 13
  • 1
  • 4
  • 1
    Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Apr 24 '18 at 19:21

2 Answers2

0

From the OpenLayers WFS-T example:

        // Word to the Wise from an anonymous OpenLayers hacker:
        //             
        // The typename in the options list when adding/loading a wfs 
        // layer not should contain the namespace before, (as in the 
        // first typename parameter to the wfs consctructor).
        // 
        // Specifically, in the first parameter you write typename: 
        // 'topp:myLayerName', and in the following option list 
        // typeName: 'myLayerName'. 
        // 
        // If you have topp included in the second one you will get 
        // namespace 14 errors when trying to insert features.
        //
        wfs = new OpenLayers.Layer.WFS(
            "Cities",
            "http://sigma.openplans.org/geoserver/wfs",
            {typename: 'topp:tasmania_cities'},
            {
                typename: "tasmania_cities",
                featureNS: "http://www.openplans.org/topp",
                extractAttributes: false,
                commitReport: function(str) {
                    OpenLayers.Console.log(str);
                }
            }
        );

Seems to indicate you are building your WFS object wrong.

Ian Turton
  • 10,018
  • 1
  • 28
  • 47
  • Practically this error only shown up when I'm using typescript especially in GML format options all attribute I assigned like featureNS always considered not assigned by writeTransactionOptions. – Teguh Santoso Apr 26 '18 at 16:17
0

I'm give up using WFS Format for build WFS Transaction request so my problem was solved by myself, I found this lib geojson-to-wfs-t-2. This library is very legit for solving my problem.

Teguh Santoso
  • 13
  • 1
  • 4