Transaction Request |
Transaction operation implements adding features, updating features, replacing features and deleting features three functions. The format is XML and the node features introduction is as follows:
Table 1 Node features for the Transaction operation
Request parameters | Required/Optional | Description |
<Transaction> |
Mandatory |
The root element to a transaction request. A Transaction feature includes zero or multiple features that used to add, update , replace, and delete. If the Transaction feature does not include Insert, Update, Replace or Delete element, the Transaction operation is meaningless. WFS service will handle elements of Insert, Update, Replace and Delete according to the order of appearance in the Transaction. A Transaction feature can also include 0 or Multiple <Natvie> elements used to describe vendor-specific operations. |
<Insert> |
Optional |
Required when adding features. The Insert element is used to create new feature instances in a web feature service's data store. By default, the initial state of a feature to be created is expressed using GML and shall validate relative to a GML application schema generated by the DescribeFeatureType operation. Multiple Insert elements may be enclosed in a single Transaction request and one feature instance can be created using a single Insert element. |
<Update> |
Optional |
Required when updating features. typeName is used to specifies the type of updating feature. The Update element contains one or more Property elements that describe a value change to be made to one of the properties of the explicitly named feature type. Multiple Update elements may be contained in a single Transaction request so that multiple changes can be made to features of the same or different types An <Update> element may contain one or multiple <Filter> elements to specify features to be updated. |
<Replace> |
Optional |
Required when replacing features. The Replace operation is used to update certain properties of the feature; while Replace operation is used to replace the entire target feature. A <Replace> element can contain one or multiple <Filter> elements, used to specify features to be deleted. |
<Delete> |
Optional |
Required when deleting features. typeName is used to specifies the type of deleting feature. A <Filter> element specify the one or multiple deleting features. |
<Native> |
Optional |
Required when adding features. The <Native> element only contains vendor-specific commands or operations and allows to the access to special WFS or data storage vendor-specific capabilities. Currently, SuperMap iServer doesn't support this parameter. |
This examples perform 4 actions to the WFS service data-world/wfs200. First add two new features. Second update a feature. Third replace a feature with another feature. Fourth delete a feature. That is performing POST request to http://localhost:8090/iserver/services/data-World/wfs200 and sending the following request body:
Execute the POST request to create feature A and feature B in World:Capitals. The CAPITAL value of feature A is testCapital and the COUNTRY value is testCountry. The CAPITAL value of feature B is testCapital2 and the COUNTRY value is testCountrys. The corresponding request body is as follows:
<wfs:Transaction version="2.0.0" service="WFS"
xmlns="http://www.someserver.example.com/myns" xmlns:wfs="http://www.opengis.net/wfs/2.0"
xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.someserver.example.com/myns ./SampleSchema.xsd
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>
<World:Capitals xmlns:World="http://www.supermap.com.cn/World">
<World:CAPITAL>testCapital</World:CAPITAL>
<World:COUNTRY>testCountry</World:COUNTRY>
<World:the_geom>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>143.09,35.57</gml:coordinates>
</gml:Point>
</World:the_geom>
</World:Capitals>
</wfs:Insert>
<wfs:Insert>
<World:Capitals xmlns:World="http://www.supermap.com.cn/World">
<World:CAPITAL>testCapital2</World:CAPITAL>
<World:COUNTRY>testCountry2</World:COUNTRY>
<World:the_geom>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>143.09,35.57</gml:coordinates>
</gml:Point>
</World:the_geom>
</World:Capitals>
</wfs:Insert>
</wfs:Transaction>
After adding the feature, please refer to Response example.
Execute the POST request to change the values of CAPITAL of feature A to otherCapital. The corresponding request body is as follows:
<?xml version="1.0" ?>
<wfs:Transaction version="2.0.0" service="WFS"
xmlns:World="http://www.someserver.example.com/myns" xmlns:fes="http://www.opengis.net/fes/2.0"
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">
<wfs:Update typeName="World:Capitals">
<wfs:Property>
<wfs:ValueReference>World/Capitals/CAPITAL</wfs:ValueReference>
<wfs:Value>otherCapital</wfs:Value>
</wfs:Property>
<fes:Filter>
<fes:PropertyIsEqualTo>
<fes:ValueReference>World/Capitals/COUNTRY</fes:ValueReference>
<fes:Literal>testCountry</fes:Literal>
</fes:PropertyIsEqualTo>
</fes:Filter>
</wfs:Update>
</wfs:Transaction>
After updating the feature, please refer to Response example.
Execute the POST request to replace element B with updated element A. After replacing features, attributes of A and B are the same, and the values for CAPITAL and COUNTRY would be otherCapital and testCountry. The corresponding request body is as follows:
<?xml version="1.0" ?>
<wfs:Transaction
version="2.0.0"
service="WFS"
xmlns:World="http://www.someserver.example.com/myns"
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: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">
<wfs:Replace>
<World:Capitals xmlns:World="http://www.supermap.com.cn/World">
<World:CAPITAL>otherCapital</World:CAPITAL>
<World:COUNTRY>testCountry</World:COUNTRY>
<World:the_geom>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>143.0901,35.5701</gml:coordinates>
</gml:Point>
</World:the_geom>
</World:Capitals>
<fes:Filter>
<fes:PropertyIsEqualTo>
<fes:ValueReference>World/Capitals/COUNTRY</fes:ValueReference>
<fes:Literal>testCountry2</fes:Literal>
</fes:PropertyIsEqualTo>
</fes:Filter>
</wfs:Replace>
</wfs:Transaction>
After replacing the feature successfully, please refer to Response example.
Execute the POST request to delete features with CAPITAL values being otherCapital in World:Capitals, that is, to delete element A and B. The corresponding request body is as follows:
<?xml version="1.0" ?>
<wfs:Transaction
version="2.0.0"
service="WFS"
xmlns:World="http://www.supermap.com.cn/World"
xmlns:fes="http://www.opengis.net/fes/2.0"
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">
<wfs:Delete typeName="World:Capitals">
<fes:Filter>
<fes:PropertyIsEqualTo>
<fes:ValueReference>World/Capitals/CAPITAL</fes:ValueReference>
<fes:Literal>otherCapital</fes:Literal>
</fes:PropertyIsEqualTo>
</fes:Filter>
</wfs:Delete>
</wfs:Transaction>
After deleting the feature, please refer to Response example.