This section presents some feature requests to the WFS engine, and the response to each request, for each of the following operations:
GetCapabilities
DescribeFeatureType
GetFeature
GetFeatureWithLock
LockFeature
Transaction, with a subelement specifying the transaction type:
Insert
Update
Delete
The XML request and response formats are similar for both relational and document-based features. Several examples in this section refer to relational features based on the COLA_MARKETS_CS table used in Example 6-17 in Example of Coordinate System Transformation, where the MKT_ID column contains the unique numeric ID of each feature, the NAME column contains each feature's name (cola_a
, cola_b
, cola_c
, or cola_d
), and the SHAPE column contains the geometry associated with each feature.
Example 15-1 GetCapabilities Request
Example 15-1 is a request to get the capabilities of the WFS server named WFS at a specified namespace URL. T.his request will return a capabilities document, as explained in Capabilities Documents
<?xml version="1.0" ?> <GetCapabilities service="WFS" version="1.0.0" xmlns="http://www.opengis.net/wfs" />
Example 15-2 GetCapabilities Response
Example 15-2 is an excerpt of the response from the request in Example 15-1.
<WFS_Capabilities xmlns="http://www.opengis.net/wfs" version="1.0.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:myns="http://www.example.com/myns"> <Service> <Name> Oracle WFS </Name> <Title> Oracle Web Feature Service </Title> <Abstract> Web Feature Service maintained by Oracle </Abstract> <OnlineResource>http://localhost:8888/SpatialWS-SpatialWS-context-root/wfsservlet</OnlineResource> </Service> <Capability> <Request> <GetCapabilities> <DCPType> <HTTP> <Get onlineResource="http://localhost:8888/SpatialWS-SpatialWS-context-root/wfsservlet"/> </HTTP> </DCPType> <DCPType> <HTTP> <Post onlineResource="http://localhost:8888/SpatialWS-SpatialWS-context-root/SpatialWSSoapHttpPort"/> </HTTP> </DCPType> </GetCapabilities> <DescribeFeatureType> <SchemaDescriptionLanguage> <XMLSCHEMA/> </SchemaDescriptionLanguage> <DCPType> <HTTP> <Post onlineResource="http://localhost:8888/SpatialWS-SpatialWS-context-root/SpatialWSSoapHttpPort"/> </HTTP> </DCPType> </DescribeFeatureType> <GetFeature> <ResultFormat> <GML2/> </ResultFormat> <DCPType> <HTTP> <Post onlineResource="http://localhost:8888/SpatialWS-SpatialWS-context-root/SpatialWSSoapHttpPort"/> </HTTP> </DCPType> </GetFeature> <GetFeatureWithLock> <ResultFormat> <GML2/> </ResultFormat> <DCPType> <HTTP> <Post onlineResource="http://localhost:8888/SpatialWS-SpatialWS-context-root/SpatialWSSoapHttpPort"/> </HTTP> </DCPType> </GetFeatureWithLock> <Transaction> <DCPType> <HTTP> <Post onlineResource="http://localhost:8888/SpatialWS-SpatialWS-context-root/SpatialWSSoapHttpPort"/> </HTTP> </DCPType> </Transaction> <LockFeature> <DCPType> <HTTP> <Post onlineResource="http://localhost:8888/SpatialWS-SpatialWS-context-root/SpatialWSSoapHttpPort"/> </HTTP> </DCPType> </LockFeature> </Request> </Capability> <FeatureTypeList> <Operations> <Insert/> <Update/> <Delete/> <Query/> <Lock/> </Operations> <FeatureType xmlns:myns="http://www.example.com/myns"> <Name> myns:COLA</Name> <Title> LIST OF COLA MARKETS </Title> <SRS> SDO:8307</SRS> </FeatureType><FeatureType xmlns:myns="http://www.example.com/myns"> <Name> myns:COLAVIEW1 </Name> <Title> LIST OF COLA MARKET VIEW </Title> <SRS> SDO:8307</SRS> </FeatureType><FeatureType xmlns:wfs="http://www.opengis.net/wfs"> <Name xmlns:myns="http://www.example.com/myns1">myns:SampleFeature</Name> <Title>SAMPLE FEATURE</Title> <SRS>EPSG:32615</SRS> </FeatureType></FeatureTypeList> <ogc:Filter_Capabilities xmlns:ogc="http://www.opengis.net/ogc"> <ogc:Spatial_Capabilities> <ogc:Spatial_Operators> <ogc:BBOX/> <ogc:Equals/> <ogc:Disjoint/> <ogc:Intersect/> <ogc:Touches/> <ogc:Crosses/> <ogc:Within/> <ogc:Contains/> <ogc:Overlaps/> <ogc:Beyond/> <ogc:DWithin/> </ogc:Spatial_Operators> </ogc:Spatial_Capabilities> <ogc:Scalar_Capabilities> <ogc:Logical_Operators/> <ogc:Comparison_Operators> <ogc:Simple_Comparisons/> <ogc:Like/> <ogc:Between/> <ogc:NullCheck/> </ogc:Comparison_Operators> <ogc:Arithmetic_Operators> <ogc:Simple_Arithmetic/> </ogc:Arithmetic_Operators> </ogc:Scalar_Capabilities> </ogc:Filter_Capabilities> </WFS_Capabilities>
Example 15-3 DescribeFeatureType Request
Example 15-3 is a request to describe the feature type named COLA
.
<?xml version="1.0" ?> <wfs:DescribeFeatureType service="WFS" version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:myns="http://www.example.com/myns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd"> <wfs:TypeName>myns:COLA</wfs:TypeName> </wfs:DescribeFeatureType>
Example 15-4 DescribeFeatureType Response
Example 15-4 is the response from the request in Example 15-3. The response is an XML schema definition (XSD).
<xsd:schema targetNamespace="http://www.example.com/myns" xmlns:wfs="http://www.opengis.net/wfs" xmlns:myns="http://www.example.com/myns" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://localhost:8888/examples/servlets/xsds/feature.xsd"/> <xsd:element name="COLA" type="myns:COLAType" substitutionGroup="gml:_Feature"/> <xsd:complexType name="COLAType"> <xsd:complexContent> <xsd:extension base="gml:AbstractFeatureType"> <xsd:sequence> <xsd:element name="MKT_ID" type="xsd:double"/> <xsd:element name="NAME" nillable="true"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="32"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="SHAPE" type="gml:PolygonMemberType" nillable="true"/> </xsd:sequence> <xsd:attribute name="fid" type="xsd:double"/> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:schema>
Example 15-5 GetFeature Request
Example 15-5 is a request to get the MKT_ID, NAME, and SHAPE properties of the feature or features of type COLA where the MKT_ID value is greater than 2 and the NAME value is equal to cola_c
, or where the MKT_ID value is greater than 3 and the NAME value is equal to cola_d
.
Note that for GetFeature and GetFeatureWithLock, the <Query>
and <PropertyName>
elements, which list the property names to be selected, can be any top-level element of the queried feature type, in which case its entire content (which may be nested) is returned in the query response. XPaths of arbitrary depth are not supported in <PropertyName>
elements directly under the <Query>
element; however, they are supported in <PropertyName>
elements in a <Filter>
element under the <Query>
element, as shown in Example 15-5 and Example 15-7
<?xml version="1.0" ?> <wfs:GetFeature service="WFS" version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:myns="http://www.example.com/myns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd"> <wfs:Query typeName="myns:COLA"> <ogc:PropertyName>myns:MKT_ID</ogc:PropertyName> <ogc:PropertyName>myns:NAME</ogc:PropertyName> <ogc:PropertyName>myns:SHAPE</ogc:PropertyName> <ogc:Filter> <ogc:And> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>myns:COLA/myns:MKT_ID</ogc:PropertyName> <ogc:Literal> 2 </ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsEqualTo> <ogc:PropertyName>myns:COLA/myns:NAME</ogc:PropertyName> <ogc:Literal>cola_c</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:And> <ogc:Or> <ogc:PropertyIsEqualTo> <ogc:PropertyName>myns:COLA/myns:MKT_ID</ogc:PropertyName> <ogc:Literal>3</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:PropertyName>myns:COLA/myns:NAME</ogc:PropertyName> <ogc:Literal>cola_d</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Or> </ogc:And> </ogc:Filter> </wfs:Query> </wfs:GetFeature>
Example 15-6 GetFeature Response
Example 15-6 is the response from the request in Example 15-5.
<?xml version = '1.0' encoding = 'UTF-8'?> <wfs:FeatureCollection xsi:schemaLocation="http://www.example.com/myns http://localhost:8888/wfsservlet?featureTypeId=1 http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <gml:boundedBy xmlns:gml="http://www.opengis.net/gml"> <gml:Box srsName="SDO:8307"> <gml:coordinates>3.0,3.0 6.0,5.0</gml:coordinates> </gml:Box> </gml:boundedBy> <gml:featureMember xmlns:gml="http://www.opengis.net/gml"> <myns:COLA fid="3" xmlns:myns="http://www.example.com/myns"> <myns:MKT_ID>3</myns:MKT_ID> <myns:NAME>cola_c</myns:NAME> <myns:SHAPE> <gml:Polygon srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml"> <gml:outerBoundaryIs> <gml:LinearRing> <gml:coordinates decimal="." cs="," ts=" ">3.0,3.0 6.0,3.0 6.0,5.0 4.0,5.0 3.0,3.0 </gml:coordinates> </gml:LinearRing> </gml:outerBoundaryIs> </gml:Polygon> </myns:SHAPE> </myns:COLA> </gml:featureMember> </wfs:FeatureCollection>
Example 15-7 GetFeatureWithLock Request
Example 15-7 is a request to get the MKT_ID, NAME, and SHAPE properties of the feature of type COLA where the MKT_ID value is greater than 2 and the NAME value is equal to cola_c
, or where the MKT_ID value is equal to 3, and to lock that feature.
<?xml version="1.0" ?> <wfs:GetFeatureWithLock service="WFS" version="1.0.0" expiry="5" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:myns="http://www.example.com/myns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <wfs:Query typeName="myns:COLA"> <ogc:PropertyName>myns:MKT_ID</ogc:PropertyName> <ogc:PropertyName>myns:NAME</ogc:PropertyName> <ogc:PropertyName>myns:SHAPE</ogc:PropertyName> <ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:PropertyName>myns:COLA/myns:MKT_ID</ogc:PropertyName> <ogc:Literal> 3 </ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> </wfs:Query> </wfs:GetFeatureWithLock>
Example 15-8 GetFeatureWithLock Response
Example 15-8 is the response from the request in Example 15-7.
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" lockId="1" xsi:schemaLocation="http://www.example.com/myns http://localhost:8888/SpatialWS-SpatialWS-context-root/wfsservlet?featureTypeId=1 " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <gml:boundedBy xmlns:gml="http://www.opengis.net/gml"> <gml:Box srsName="SDO:8307"> <gml:coordinates>3.0,3.0 6.0,5.0</gml:coordinates> </gml:Box> </gml:boundedBy> <gml:featureMember xmlns:gml="http://www.opengis.net/gml"> <myns:COLA xmlns:myns="http://www.example.com/myns" fid="3"> <myns:MKT_ID>3</myns:MKT_ID> <myns:NAME>cola_c</myns:NAME> <myns:SHAPE> <gml:Polygon srsName="SDO:8307"> <gml:outerBoundaryIs> <gml:LinearRing> <gml:coordinates decimal="." cs="," ts=" ">3.0,3.0 6.0,3.0 6.0,5.0 4.0,5.0 3.0,3.0 </gml:coordinates> </gml:LinearRing> </gml:outerBoundaryIs> </gml:Polygon> </myns:SHAPE> </myns:COLA> </gml:featureMember> </wfs:FeatureCollection>
Example 15-9 LockFeature Request
Example 15-9 is a request to lock the feature where the MKT_ID value is equal to 2.
<?xml version="1.0" ?> <wfs:LockFeature service="WFS" version="1.0.0" expiry="5" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:myns="http://www.example.com/myns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <wfs:Lock typeName="myns:COLA"> <ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:PropertyName>myns:COLA/myns:MKT_ID</ogc:PropertyName> <ogc:Literal> 2 </ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> </wfs:Lock> </wfs:LockFeature>
Example 15-10 LockFeature Response
Example 15-10 is the response from the request in Example 15-9.
<wfs:WFS_LockFeatureResponse xmlns:wfs="http://www.opengis.net/wfs"> <wfs:LockId>2</wfs:LockId> </wfs:WFS_LockFeatureResponse>
Example 15-11 Insert Request
Example 15-11 is a request to insert a feature, with MKT_ID = 5 and NAME = cola_e
, into the table associated with the WFS service named WFS
.
<?xml version="1.0"?> <wfs:Transaction version="1.0.0" handle="TX01" service="WFS" xmlns="http://www.e xample.com/myns" xmlns:myns="http://www.example.com/myns" xmlns:gml="http://ww w.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www. opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <wfs:Insert handle="INSERT01" > <myns:COLA fid="5" xmlns:myns="http://www.example.com/myns"> <myns:MKT_ID>5</myns:MKT_ID> <myns:NAME>cola_e</myns:NAME> <myns:SHAPE> <gml:Polygon srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml"> <gml:outerBoundaryIs> <gml:LinearRing> <gml:coordinates decimal="." cs="," ts=" ">1.0,3.0 6.0,3.0 6.0,5.0 4.0,5.0 1.0,3.0 </gml:coordinates> </gml:LinearRing> </gml:outerBoundaryIs> </gml:Polygon> </myns:SHAPE> </myns:COLA> </wfs:Insert> </wfs:Transaction>
Example 15-12 Insert Response
Example 15-12 is the response from the request in Example 15-11.
<?xml version = '1.0' encoding = 'UTF-8'?> <wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs"> <wfs:InsertResult handle="INSERT01"> <ogc:FeatureId fid="5" xmlns:ogc="http://www.opengis.net/ogc"/> </wfs:InsertResult> <wfs:TransactionResult handle="TX01"> <wfs:Status> <wfs:SUCCESS/> </wfs:Status> </wfs:TransactionResult> </wfs:WFS_TransactionResponse>
Example 15-13 Update Request
Example 15-13 is a request to update the feature, where MKT_ID is greater than 2 and less than 4 and where NAME is not null, in the table associated with the WFS service named WFS
. This request specifies that the NAME value of the specified feature is to be set to cola_cl
.
<?xml version="1.0"?> <wfs:Transaction version="1.0.0" handle="TX01" service="WFS" xmlns="http://www.example.com/myns" xmlns:myns="http://www.example.com/myns" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www. opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <wfs:Update handle="UPDATE1" typeName="myns:COLA" > <wfs:Property> <wfs:Name>myns:COLA/myns:NAME</wfs:Name> <wfs:Value>cola_c1</wfs:Value> </wfs:Property> <ogc:Filter> <ogc:And> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>myns:COLA/myns:MKT_ID</ogc:PropertyName> <ogc:Literal> 2 </ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThan> <ogc:PropertyName>myns:COLA/myns:MKT_ID</ogc:PropertyName> <ogc:Literal> 4 </ogc:Literal> </ogc:PropertyIsLessThan> </ogc:And> <ogc:Not> <ogc:PropertyIsNull> <ogc:PropertyName>myns:COLA/myns:NAME</ogc:PropertyName> </ogc:PropertyIsNull> </ogc:Not> </ogc:And> </ogc:Filter> </wfs:Update> </wfs:Transaction>
Example 15-14 Update Response
Example 15-14 is the response from the request in Example 15-13.
<?xml version = '1.0' encoding = 'UTF-8'?> <wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs"> <wfs:TransactionResult handle="TX01"> <wfs:Status> <wfs:SUCCESS/> </wfs:Status> </wfs:TransactionResult> </wfs:WFS_TransactionResponse>
Example 15-15 Delete Request
Example 15-15 is a request to delete the feature, where MKT_ID is greater than 3 and NAME is equal to cola_e
and is not null, in the table associated with the WFS service named WFS
.
<?xml version="1.0"?> <wfs:Transaction version="1.0.0" handle="TX01" service="WFS" xmlns="http://www.example.com/myns" xmlns:myns="http://www.example.com/myns" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www. opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <wfs:Delete handle="DELETE1" typeName="myns:COLA" > <ogc:Filter> <ogc:And> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>myns:COLA/myns:MKT_ID</ogc:PropertyName> <ogc:Literal> 3 </ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsEqualTo> <ogc:PropertyName>myns:COLA/myns:NAME</ogc:PropertyName> <ogc:Literal> cola_e </ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:And> <ogc:Not> <ogc:PropertyIsNull> <ogc:PropertyName>myns:COLA/myns:NAME</ogc:PropertyName> </ogc:PropertyIsNull> </ogc:Not> </ogc:And> </ogc:Filter> </wfs:Delete> </wfs:Transaction>
Example 15-16 Delete Response
Example 15-16 is the response from the request in Example 15-15.
<?xml version = '1.0' encoding = 'UTF-8'?> <wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs"> <wfs:TransactionResult handle="TX01"> <wfs:Status> <wfs:SUCCESS/> </wfs:Status> </wfs:TransactionResult> </wfs:WFS_TransactionResponse>