geoserver wfs-t是只读异常 [英] geoserver wfs-t is read-only exception

查看:409
本文介绍了geoserver wfs-t是只读异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用GeoServer通过WFS-T保存更改: 这是我的代码正在从geoserver获取功能

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表已经具有主键,创建脚本:

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;

你能帮我吗?

推荐答案

您需要在GeoServer中进行两件事更改才能使之成为可能.

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

  1. 在GeoServer的"WFS"标签下启用事务处理
  2. 在GeoServer的数据"标签下,您需要编辑规则..w以启用角色ROLE_ANONYMOUS

完成这两项操作后,我可以摆脱此错误并将数据发布到GeoServer.

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

这篇关于geoserver wfs-t是只读异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆