Transaction Request |
Transaction operation supports the functions of adding elements, updating elements, replacing elements 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 |
The root element when the transaction request isexecuted. A Transaction element can contain 0 or more Insert, Update, Replace for adding, updating, replacing, or deleting elements Or Delete element. When the Transaction element does not contain Insert, Update, Replace, or Delete Element, the Transaction operation is meaningless. The WFS service requests Insert, Update, Replace, And Delete elements are processed in the order in which they appear. The Transaction element can also contain zero or more Native elements that describe vendor-specific actions. |
<Insert> |
No |
Required for the add new element operation. The Insert element is used to add a new feature to the data store of the WFS service. By default, the GML language is used to express the initial state of the newly added feature, and the initial state of the newly added feature should be expressed using the Describe FeatureType validates the GML schema described by the operation. A Transaction request can contain multiple Insert elements. One element can be added to each Insert element. |
<Update> |
No |
Required for update element operations. Use the typeName attribute to specify the type of feature that needs to be updated. The Update element can contain one or more Property elements that specify the attributes (Value References) of the elements that need to be updated Element) and an attribute value (Value element). A Transaction request can contain multiple Update elements to implement multiple element updates of the same or different types. The Update element can contain one or more Filter elements that specify the elements to be updated. |
<Replace> |
No |
Required for the replace element operation. The Replace operation differs from the Update operation in that it updates the individual attributes of an element, while the Replace operation completely replaces the target element with the specified element. After the replacement, the attribute values of the two elements are the same. The Replace element can contain one or more Filter elements that specify the features to be replaced. |
<Delete> |
No |
Required for element deletion. Use the typeName attribute to specify the type of feature to be deleted. The Delete element can contain one or more Filter elements that specify the features to be deleted. |
<Native> |
No |
Required for the Add New Element operation. Native elements contain only vendor-specific commands or actions, allowing access to the vendor-specific capabilities of a particular WFS or data store. This parameter is not currently supported by SuperMap iServer. |
In this example, four Transaction operations are performed on the WFS service data-world/wfs200. First, two new elements are added (for the sake of introduction, assume that the two elements are A, B), then the element A is updated, then the element B is replaced by the updated element A, and finally the elements A and B with the same attribute value are deleted. That is, the http://localhost:8090/iserver/services/data-World/wfs200 Execute the POST request and transmit the following request bodies respectively:
Execute POST request and create two features, A and B, in the World: Capitals layer. The CAPITAL field value for element A is testCapital and the COUNTRY field value is testCountry, while the CAPITAL field value for element B is testCapital2 and the COUNTRY field value is testCountry2. 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="https://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="https://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 the element is added successfully, the response is shown in the Response example .
Execute the POST request and change the CAPITAL field value of the element 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 the element is updated successfully, the response is shown in the Response example .
Note: The namespace defined in the WFS: Transaction root node should correspond to the value in typeName, such as namespace xmlns:World="http://www.someserver.example.com/myns", typeName value of is World:Capitals.
Execute the POST request and replace the element B with the updated element A. After the replacement, the attribute values of the elements A and B are the same, CAPITAL field value is other Capital and the COUNTRY field value is 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="https://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 the element is replaced successfully, the response is shown in the Response example .
Execute the POST request and set the value of CAPITAL field in the World:Capitals layer to otherCapital. Delete the elements of, that is, delete the two elements A and B. The corresponding request body is as follows:
<?xml version="1.0" ?>
<wfs:Transaction
version="2.0.0"
service="WFS"
xmlns:World="https://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 the element is deleted successfully, the response is shown in the Response example .
Note: The namespace defined in the WFS: Transaction root node should correspond to the value in typeName, such as namespace xmlns:World="https://www.supermap.com.cn/World", value of typeName is World:Capitals.