geoserver wfs-t is read-only exception

99封情书 提交于 2020-04-21 07:10:46

问题


I am trying to save changes via WFS-T using GeoServer: This is my code that is getting feature from geoserver

var sourceWFS = new ol.source.Vector({
    loader: function (extent) {
        $.ajax('http://127.0.0.1:8080/geoserver/kairosDB/ows', {
            type: 'GET',
            data: {
                service: 'WFS',
                version: '1.1.0',
                request: 'getFeature',
                typename: 'wfs_geom',
                srsname: 'EPSG:3857',
                bbox: extent.join(',') + ',EPSG:3857'
            }
        }).done(function (response) {
            sourceWFS.addFeatures(formatWFS.readFeatures(response));
        });
    },
    // strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ()),
    strategy: ol.loadingstrategy.bbox,
    projection: 'EPSG:3857'
});

And This is code that is saving feature to server

var formatGML = new ol.format.GML({
    featureNS: 'http://127.0.0.1:8080/geoserver/kairosDB',
    featureType: 'wfs_geom',
    srsName: 'EPSG:3857'
});

But When I saveFeature to server, This error's occured

2017-02-01 14:30:02,339 ERROR [geoserver.ows] - 
org.geoserver.wfs.WFSTransactionException: {http://127.0.0.1:8080/geoserver/kairosDB}wfs_geom is read-only
    at org.geoserver.wfs.Transaction.execute(Transaction.java:269)
    at org.geoserver.wfs.Transaction.transaction(Transaction.java:106)
    at org.geoserver.wfs.DefaultWebFeatureService.transaction(DefaultWebFeatureService.java:172)
    at sun.reflect.GeneratedMethodAccessor195.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

wfs_geom table already has a primary key, create script:

CREATE TABLE public.wfs_geom
(
    id bigint NOT NULL,
    geometry geometry,
    CONSTRAINT wfs_geom_pkey PRIMARY KEY (id)
)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

ALTER TABLE public.wfs_geom
    OWNER to postgres;

GRANT ALL ON TABLE public.wfs_geom TO postgres;

-- Index: sidx_wfs_geom

-- DROP INDEX public.sidx_wfs_geom;

CREATE INDEX sidx_wfs_geom
    ON public.wfs_geom USING gist
    (geometry)
    TABLESPACE pg_default;

Could you help me?


回答1:


This works like a charm: http://osgeo-org.1560.x6.nabble.com/Read-only-error-when-editing-a-WFS-T-td5284537.html

There is a rule in the "Data security" section that do allow to write to this workspace for all, but the writing is not allowed to anonymous user for all the workspace (..w) The strange behaviour is that in yesterday I can edit the layer using a client.. and I do not understand why, moreover using QGIS I cannot edit the layer, but QGIS support the WFS-T




回答2:


There are two things you need to change in GeoServer to makes this possible.

  1. Enable Transactional under the WFS tab on GeoServer
  2. Under the Data tab on GeoServer you need to edit the rule ..w to enable the role ROLE_ANONYMOUS

After doing these two things I was able to get rid of this error and post data to GeoServer.



来源:https://stackoverflow.com/questions/41972613/geoserver-wfs-t-is-read-only-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!