Allowing read-write access to vector data through transactions

Boundless Server Enterprise (BSE) contains a full Web Feature Service (WFS) implementation. This also includes support for WFS Transactions (WFS-T).

However, as unrestricted write access to data is a security risk, the WFS in Boundless Server Enterprise is set to “Basic” by default. This means that the only requests that will be accepted are:

  • GetCapabilites
  • DescribeFeatureType
  • GetFeature

To enable WFS-T, you will need to change the WFS Service Level in GeoServer to Transactional (or Complete).

  1. Open the GeoServer admin interface.

  2. Under the Services section, click WFS.

    ../../_images/wfslink.png

    WFS in the Services menu

  3. Scroll down to Service Level. Click the box next to Transactional.

    ../../_images/wfst-basic.png

    Default setting: WFS-T not allowed

    ../../_images/wfst-transactional.png

    WFS-T allowed

  4. Click Save.

Testing WFS transactions

To test WFS transactions you will need an editable vector data set such as a PostGIS layer.

The simplest option is to test using whatever client you plan to use in production such as QGIS. If that is not possible, you can use the following instructions to run an insert transaction manually.

This example uses a point feature type boundless_offices in the workspace example with a namespace of http://www.boundlessgeo.com/example. You can alter it to fit other feature types.

PostGIS schema for boundless_offices
create table boundless_offices
(
  id serial not null primary key,
  geom geometry(Point,4326),
  city varchar not null unique
);

Create an XML file for the insert transaction.

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction
   version="2.0.0"
   service="WFS"
   xmlns:example="http://www.boundlessgeo.com/example"
   xmlns:gml="http://www.opengis.net/gml/3.2"
   xmlns:wfs="http://www.opengis.net/wfs/2.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/wfs/2.0
                       http://schemas.opengis.net/wfs/2.0/wfs.xsd
                       http://www.opengis.net/gml/3.2
                       http://schemas.opengis.net/gml/3.2.1/gml.xsd">
   <wfs:Insert>
    <example:boundless_offices>
      <example:geom>
        <gml:Point srsName="http://www.opengis.net/def/crs/epsg/0/4326">
          <gml:coordinates>48.42319,-123.36600</gml:coordinates>
        </gml:Point>
      </example:geom>
      <example:city>Victoria</example:city>
    </example:boundless_offices>
   </wfs:Insert>
</wfs:Transaction>

Make adjustments to fit your data

   xmlns:example="http://www.boundlessgeo.com/example"

Replace the example namespace with that for your workspace

    <example:boundless_offices>
      <example:geom>
        <gml:Point srsName="http://www.opengis.net/def/crs/epsg/0/4326">
          <gml:coordinates>48.42319,-123.36600</gml:coordinates>
        </gml:Point>
      </example:geom>
      <example:city>Victoria</example:city>
    </example:boundless_offices>

Replace example with the namespace identifier you specified above. Replace boundless_offices with the name of your layer, and replace the attributes geom and city with the attributes in your data. You may need more or fewer attributes.

    <example:boundless_offices>
      <example:geom>
        <gml:Point srsName="http://www.opengis.net/def/crs/epsg/0/4326">
          <gml:coordinates>48.42319,-123.36600</gml:coordinates>
        </gml:Point>
      </example:geom>
      <example:city>Victoria</example:city>
    </example:boundless_offices>

Replace the GML geometry with one appropriate for your layer. For more details, see the GML 3.2 specification.

When you have set up your transaction, you can execute it via curl or a similar HTTP client.

curl -u admin:geoserver -XPOST -H "Content-type: text/xml" -d @insert.xml http://localhost:8080/geoserver/ows

Replace admin:geoserver with your username and password, insert.xml with the path to your transaction XML, and localhost:8080 with the host where you are running BSE. The result you get back should look like the following if you were successful.

<?xml version="1.0" encoding="UTF-8"?>
<wfs:TransactionResponse
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:fes="http://www.opengis.net/fes/2.0"
    xmlns:wfs="http://www.opengis.net/wfs/2.0"
    xmlns:gml="http://www.opengis.net/gml/3.2"
    xmlns:ows="http://www.opengis.net/ows/1.1"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="2.0.0"
    xsi:schemaLocation="http://www.opengis.net/wfs/2.0
			http://localhost:8080/geoserver/schemas/wfs/2.0/wfs.xsd">
    <wfs:TransactionSummary>
      <wfs:totalInserted>1</wfs:totalInserted>
      <wfs:totalUpdated>0</wfs:totalUpdated>
      <wfs:totalReplaced>0</wfs:totalReplaced>
      <wfs:totalDeleted>0</wfs:totalDeleted>
    </wfs:TransactionSummary>
    <wfs:InsertResults>
        <wfs:Feature>
            <fes:ResourceId rid="boundless_offices.5"/>
        </wfs:Feature>
    </wfs:InsertResults>
</wfs:TransactionResponse>

Notice that the TransactionSummary shows 1 insert, and the InsertResults shows one Feature indicating that the insertion was successful.