GEOSS Banner

2.2.5 : Transactional WFS

A transactional WFS server (many times referred to as WFS-T) shall implement the Basic WFS operations and it shall also implement the Transaction operation. The transaction operation is a 4 in 1 operation that changes the direction of the information flow. With this operation the user is able to send information to the server and update the data stored in the server. The data becomes immediately available to others. It is composed of 4 operations: "insert", "update” and "delete" and other possible vendor specific operations using the "native" operation.


2.2.5.1 Implementing an Insert Transaction: Required Parameters
2.2.5.2 Insert transaction response.
2.2.5.3 Implementing an Update Transaction: Required Parameters
2.2.5.4 Update transaction response.
2.2.5.5 Implementing a Delete Transaction: Required Parameters
2.2.5.6 Delete transaction response


<<Prev T.O.C.  Next>>

2.2.5.1 Implementing an Insert Transaction: Required Parameters

It will be more complicated to illustrate this feature, mainly because the data that has to be sent to the server can not be easily carried through the URL in the form of key and value pairs (what is known as HTTP-GET method with KVP parameters), but it has to be transported in an XML file.

In this example, we are going to use the Haiti SDI VGI WFS-T example (https://geossregistries.info/geosspu...8-dfed4d3fe9ef). It is a Web Feature Server implemented using the CubeWerx Suite 5.5.2.

We know this service supports transactions because the OperationsMetadata section in the Capabilities document declares to support this operation (http://portal.cubewerx.com/cubewerx/...etCapabilities):

 

<ows:OperationsMetadata>

<ows:Operation name="GetCapabilities">[…]</ows:Operation>

<ows:Operation name="DescribeFeatureType">[…]</ows:Operation>

<ows:Operation name="GetFeature">[…]</ows:Operation>

<ows:Operation name="Transaction">[…]</ows:Operation>

<ows:DCP>

<ows:HTTP>

<ows:Post xlink:href="http://portal.cubewerx.com/cubewerx/...;DATASTORE=vgi"/>

</ows:HTTP>

</ows:DCP>

[…]

<ows:Parameter name="idgen">

<ows:Value>GenerateNew</ows:Value>

</ows:Parameter>

[…]

</ows:Operation>

[…]

<ows:OperationsMetadata>

From the set of FeatureTypes available on this service we have chosen one that is called cw:POINTS.

 

<FeatureType>

<Name>cw:POINTS</Name>

<Title>Points of Interest</Title>

<DefaultSRS>EPSG:4326</DefaultSRS>

<ows:WGS84BoundingBox>

<ows:LowerCorner>-74.4074639 17.8961279</ows:LowerCorner>

<ows:UpperCorner>-68.3466872 20.0086847</ows:UpperCorner>

</ows:WGS84BoundingBox>

</FeatureType>

 

 

 

We also know the GML application schema that describes them using http://portal.cubewerx.com/cubewerx/...Name=cw:POINTS:

<xs:schema targetNamespace="http://www.cubewerx.com/cw" xmlns:cw="http://www.cubewerx.com/cw" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" xmlns:cwmeta="http://www.cubewerx.com/cwmeta" elementFormDefault="qualified" version="1.0">

<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>

<xs:import namespace="http://www.cubewerx.com/cwmeta" schemaLocation="http://www.cubewerx.com/schemas/cwme...0.0/cwmeta.xsd"/>

<xs:element name="POINTS" type="cw:POINTSType" substitutionGroup="gml:_Feature"/>

<xs:complexType name="POINTSType">

<xs:complexContent>

<xs:extension base="gml:AbstractFeatureType">

<xs:sequence>

<xs:element name="POINTS.GEOMETRY" type="gml:PointPropertyType"/>

<xs:element name="POINTS.OSM_ID" minOccurs="0">

<xs:simpleType>

<xs:restriction base="xs:integer">

<xs:totalDigits value="10"/>

</xs:restriction>

</xs:simpleType>

</xs:element>

<xs:element name="POINTS.TIMESTAMP_" minOccurs="0">

<xs:simpleType>

<xs:restriction base="xs:string">

<xs:maxLength value="20"/>

</xs:restriction>

</xs:simpleType>

</xs:element>

<xs:element name="POINTS.NAME" minOccurs="0">

<xs:simpleType>

<xs:restriction base="xs:string">

<xs:maxLength value="48"/>

</xs:restriction>

</xs:simpleType>

</xs:element>

<xs:element name="POINTS.TYPE_" minOccurs="0">

<xs:simpleType>

<xs:restriction base="xs:string">

<xs:maxLength value="16"/>

</xs:restriction>

</xs:simpleType>

</xs:element>

</xs:sequence>

</xs:extension>

</xs:complexContent>

</xs:complexType>

</xs:schema>

 

We can also get the current content of the Features of this feature type by doing:
http://portal.cubewerx.com/cubewerx/...Name=cw:POINTS.

image19.png


A particular point looks like:

<gml:featureMember>

<POINTS gml:id="CWFID.POINTS.0.0.61CB7559D106A1BE1F20020000">

<POINTS.GEOMETRY>

<gml:Point srsName="EPSG:4326">

<gml:pos>-74.1659157 18.2752643</gml:pos>

</gml:Point>

</POINTS.GEOMETRY>

<POINTS.OSM_ID>616162720</POINTS.OSM_ID>

<POINTS.TIMESTAMP_>2010-01-18T11:43:29Z</POINTS.TIMESTAMP_>

<POINTS.NAME>2010-01-18T11:43:29Z</POINTS.NAME>

<POINTS.TYPE_>place_of_worship</POINTS.TYPE_>

</POINTS>

</gml:featureMember>

 


Note that this particular server is not honoring the OGC axis ordering policy, so we have to order the coordinates in longitude-latitude ordering.

Now we have enough information to prepare a new point to be inserted in the server. We are going to insert "Barcelona" in the data because it will be clearly visible as a point far away from Haiti. We have to prepare an XML file that looks like the feature collection we have just downloaded but with different headers:


<?xml version="1.0" encoding="UTF-8"?>

<wfs:Transaction version="1.1.0" service="WFS" xmlns="http://www.cubewerx.com/cw" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cubewerx.com/cw http://portal.cubewerx.com/cubewerx/...pengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/feature.xsd">

<wfs:Insert idgen="GenerateNew">

<POINTS gml:id="Catalonia">

<POINTS.GEOMETRY>

<gml:Point srsName="EPSG:4326">

<gml:pos>2.17 41.39</gml:pos>

</gml:Point>

</POINTS.GEOMETRY>

<POINTS.OSM_ID>1111</POINTS.OSM_ID>

<POINTS.TIMESTAMP_>2011-08-14T11:00:00Z</POINTS.TIMESTAMP_>

<POINTS.NAME>Barcelona</POINTS.NAME>

<POINTS.TYPE_>Non Haiti place</POINTS.TYPE_>

</POINTS>

</wfs:Insert>

</wfs:Transaction>

Let's save this file as insert.xml. To transfer an XML to a server without a specifically developed WFS-T client application, can be done by using the gnu wget application (http://gnuwin32.sourceforge.net/packages/wget.htm). The wget application has an optional parameter "--post-file=file_name" that allows us to send some file to the service as a POST method. We have also to specify --header="Content-Type:text/xml to report that we are transferring an xml file. This is the complete syntax:

wget -O insert_response.xml --post-file="insert_request.xml" --header="Content-Type:text/xml http://portal.cubewerx.com/cubewerx/...&DATASTORE=vgi

 

2.2.5.2. Insert transaction response.

To a correct transaction request the service will answer with a transaction report. The previous example report is:


<wfs:TransactionResponse xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" 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 http://www.opengis.net/ogc http://schemas.opengis.net/filter/1.1.0/filter.xsd" version="1.1.0">

<wfs:TransactionSummary>

<wfs:totalInserted>1</wfs:totalInserted>

<wfs:totalUpdated>0</wfs:totalUpdated>

<wfs:totalDeleted>0</wfs:totalDeleted>

</wfs:TransactionSummary>

<wfs:InsertResults>

<wfs:Feature handle="Action #1">

<ogc:FeatureId fid="CWFID.POINTS.0.1454.C546D1DB448763701F20020000"/>

</wfs:Feature>

</wfs:InsertResults>

</wfs:TransactionResponse>

As you can see, we have inserted a new object that has received a new gml:id because we requested that by indicating: idgen="GenerateNew".

We can get the features of the cw:POINTS feature type again: http://portal.cubewerx.com/cubewerx/...Name=cw:POINTS and we get:

 

image20.png

Where you can see our new feature as the last one:

 

<gml:featureMember>

<POINTS gml:id="CWFID.POINTS.0.1454.C546D1DB448763701F20020000">

<POINTS.GEOMETRY>

<gml:Point srsName="EPSG:4326">

<gml:pos>2.17 41.39</gml:pos>

</gml:Point>

</POINTS.GEOMETRY>

<POINTS.OSM_ID>1111</POINTS.OSM_ID>

<POINTS.TIMESTAMP_>2011-08-14T11:00:00Z</POINTS.TIMESTAMP_>

<POINTS.NAME>Barcelona</POINTS.NAME>

<POINTS.TYPE_>Non Haiti place</POINTS.TYPE_>

</POINTS>

</gml:featureMember>

 

2.5.3 Implementing an Update Transaction: Required Parameters

We are going to update the OSM_ID that we have introduced in our previous example. We have to prepare a transaction file with a point for updating it in the server. The file looks similar to the previous one but with some modifications:

<wfs:Transaction version="1.1.0" service="WFS" xmlns="http://www.cubewerx.com/cw" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cubewerx.com/cw http://portal.cubewerx.com/cubewerx/...pengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/feature.xsd">

<wfs:Update typeName="cw:POINTS">

<wfs:Property>

<wfs:Name>cw:POINTS.OSM_ID</wfs:Name>

<wfs:Value>9999</wfs:Value>

</wfs:Property>

<ogc:Filter>

<ogc:FeatureId fid="CWFID.POINTS.0.1454.C546D1DB448763701F20020000"/>

</ogc:Filter>

</wfs:Update>

</wfs:Transaction>

 

Let's save this file as update.xml and transfer the file to the server again:


wget -O update_response.x
ml --post-file="update_request.xml" --header="Content-Type:text/xml" "http://portal.cubew
erx.com/cubewerx/cubeserv/cubeserv.cgi?CONFIG=haiti_vgi&DATASTORE=vgi"

2.2.5.4. Update transaction response.

To a correct transaction request the service will answer with a transaction report. In our previous example the report is:

<wfs:TransactionResponse xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" 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 http://www.opengis.net/ogc http://schemas.opengis.net/filter/1.1.0/filter.xsd" version="1.1.0">

<wfs:TransactionSummary>

<wfs:totalInserted>0</wfs:totalInserted>

<wfs:totalUpdated>1</wfs:totalUpdated>

<wfs:totalDeleted>0</wfs:totalDeleted>

</wfs:TransactionSummary>

<wfs:InsertResults/>

</wfs:TransactionResponse>

 


We can get the features of the cw:POINTS feature type again and see our updated feature as the last one:

 

<gml:featureMember>

<POINTS gml:id="CWFID.POINTS.0.1454.C546D1DB448763701F20020000">

<POINTS.GEOMETRY>

<gml:Point srsName="EPSG:4326">

<gml:pos>2.17 41.39</gml:pos>

</gml:Point>

</POINTS.GEOMETRY>

<POINTS.OSM_ID>9999</POINTS.OSM_ID>

<POINTS.TIMESTAMP_>2011-08-14T11:00:00Z</POINTS.TIMESTAMP_>

<POINTS.NAME>Barcelona</POINTS.NAME>

<POINTS.TYPE_>Non Haiti place</POINTS.TYPE_>

</POINTS>

</gml:featureMember>

 

2.2.5.5 Implementing a Delete Transaction: Required Parameters

We are going to delete the feature we introduced in our previous example to leave the dataset clean again. We have to prepare a transaction file with a point for updating it in the server. Te file looks similar to the previous one but with some modifications:

<wfs:Transaction version="1.1.0" service="WFS" xmlns="http://www.cubewerx.com/cw" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cubewerx.com/cw http://portal.cubewerx.com/cubewerx/...pengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/feature.xsd">

<wfs:Delete typeName="cw:POINTS">

<ogc:Filter>

<ogc:FeatureId fid=" CWFID.POINTS.0.1454.C546D1DB448763701F20020000"/>

</ogc:Filter>

</wfs:Delete>

</wfs:Transaction>

 

Let's save this file as update.xml and transfer the file to the server again:

wget -O delete_response.x
ml --post-file="delete_request.xml" --header="Content-Type:text/xml" "http://portal.cubew erx.com/cubewerx/cubeserv/cubeserv.cgi?CONFIG=haiti_vgi&DATASTORE=vgi"

2.2.5.6. Delete transaction response

To a correct transaction request the service will answer with a transaction report. In our previous example the report is:

<wfs:TransactionResponse xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" 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 http://www.opengis.net/ogc http://schemas.opengis.net/filter/1.1.0/filter.xsd" version="1.1.0">

<wfs:TransactionSummary>

<wfs:totalInserted>0</wfs:totalInserted>

<wfs:totalUpdated>0</wfs:totalUpdated>

<wfs:totalDeleted>1</wfs:totalDeleted>

</wfs:TransactionSummary>

<wfs:InsertResults/>

</wfs:TransactionResponse>

 



<<Prev T.O.C.  Next>>
Tag
none

Files (0)

 
You must login to post a comment.