Transaction Request |
Transaction operation realizes three functions of adding, updating and deleting elements through POST request, and the request body adopts in XML format, the main node elements are described as follows:
Table 1 Transaction Operation Request Body Node Element
Request parameters | Whether it is required | Description |
<Transaction> | Yes |
A transaction element includes 0 or more <Insert>, <Update>, or <Delete> elements used for adding, updating, or deleting elements. Allow <Transaction> The element is empty, that is, it contains no other elements, and the Transaction operation has no meaning. |
<Insert> | No | Required for adding features. The feature to be added needs to be described in GML language through the <feature> element. You can add more than one element in a <Insert> element. |
<Update> | No | Required for element update. Where the typeName parameter specifies the type of feature that needs to be updated. An <Update> element can contain one or more <Property> elements that specify the attributes (<Name> elements) and attribute values (<Value> elements) of the elements to be updated. In the absence of a <Value> element, the attribute is assigned a null value. The <Update> element also contains the <Filter> element, which is used to limit the range of elements to be updated. There can be one or more elements. See the request example for details. |
<Delete> | No | Required for element deletion. The typeName parameter specifies the type of feature to be deleted. The elements to be deleted are specified through the <Filter> element, which can be one or more. |
In this example, three Transaction operations are performed on the WFS service data-world/wfs100. First, a new element is added, then the element is updated, and finally the element is deleted. That is, http://localhost:8090/iserver/services/data-World/wfs100?request=Transaction , execute the POST request and transmit the following request bodies respectively:
Execute the POST request and create a sample capital named testCapital in the World:Capitals layer. The request body is:
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs"
service="WFS" version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd https://www.supermap.com/World http://localhost:8090/iserver/services/data-World/wfs100?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=World:Capitals">
<wfs:Insert>
<World:Capitals xmlns:World="https://www.supermap.com/World">
<World:CAPITAL>testCapital</World:CAPITAL>
<World:COUNTRY>testCountry</World:COUNTRY>
<World:the_geom>
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:coordinates>143.09,35.57</gml:coordinates>
</gml:Point>
</World:the_geom>
</World:Capitals>
</wfs:Insert>
</wfs:Transaction>
After the element is added successfully, the response is shown in the Response example .
Execute the POST request, change the capital of the testCountry country to "otherCapital", The body of the request is:
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs"
service="WFS" version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd https://www.supermap.com/World http://localhost:8090/iserver/services/data-world/wfs100?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=World:Capitals">
<wfs:Update typeName="World:Capitals" xmlns:World="https://www.supermap.com/World">
<wfs:Property>
<wfs:Name>CAPITAL</wfs:Name>
<wfs:Value>otherCapital</wfs:Value>
</wfs:Property>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>COUNTRY</ogc:PropertyName>
<ogc:Literal>testCountry</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
After the element is updated successfully, the response is shown in the Response example .
Execute the POST request to delete the element with the CAPITAL field named "otherCapital" in the World: Capitals layer. The request body is:
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs"
service="WFS" version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd https://www.supermap.com/World http://localhost:8090/iserver/services/data-world/wfs100?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=World:Capitals">
<wfs:Delete typeName="feature:Capitals" xmlns:feature="https://www.supermap.com/World">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>CAPITAL</ogc:PropertyName>
<ogc:Literal>otherCapital</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Delete>
</wfs:Transaction>
After the element is deleted successfully, the response is shown in the Response example .