ArcGISServer10中支持的WFS版本为最新的1.1.0。在ArcGISServer 中,叧需简单地勾选的Capabilities选项卡中可以选择支持WFS,如图 19。如果勾选了Transaction复选框,那么通过该WFS 还可以进行数据更新(注意,需要是SDE数据源)。
图19ArcGISServer发布WFS服务
现在我们在浏览器中执行一个GetFeature操作,查询名为“Beijing”的对象:
http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer?
request=getfeature&
typename=test_wfsTest:sde_cities&
filter=(
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>CITY_NAME</ogc:PropertyName>
<ogc:Literal>Beijing</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
)
这个操作返回如下的结果:
<wfs:FeatureCollection
xsi:schemaLocation='http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer?request=DescribeFeatureType%26version=1.1.0%26typename=sde_cities http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd'
xmlns:test_wfsTest='http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer'
xmlns:gml='http://www.opengis.net/gml' xmlns:wfs='http://www.opengis.net/wfs'
xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<gml:boundedBy>
<gml:Envelope srsName='urn:ogc:def:crs:EPSG:6.9:4326'>
<gml:lowerCorner>-86.002616990000007
-176.15156363599999</gml:lowerCorner>
<gml:upperCorner>102.93161888100001
179.22188769499999</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
<test_wfsTest:sde_cities gml:id='F3__474'>
<test_wfsTest:OBJECTID>474</test_wfsTest:OBJECTID>
<test_wfsTest:CITY_NAME>Beijing</test_wfsTest:CITY_NAME>
<test_wfsTest:GMI_ADMIN>CHN-BJN</test_wfsTest:GMI_ADMIN>
<test_wfsTest:ADMIN_NAME>Beijing</test_wfsTest:ADMIN_NAME>
<test_wfsTest:FIPS_CNTRY>CH</test_wfsTest:FIPS_CNTRY>
<test_wfsTest:CNTRY_NAME>China</test_wfsTest:CNTRY_NAME>
<test_wfsTest:STATUS>National and provincial capital</test_wfsTest:STATUS>
<test_wfsTest:POP_RANK>1</test_wfsTest:POP_RANK>
<test_wfsTest:POP_CLASS>5,000,000 and greater</test_wfsTest:POP_CLASS>
<test_wfsTest:PORT_ID>0</test_wfsTest:PORT_ID>
<test_wfsTest:LABEL_FLAG>1</test_wfsTest:LABEL_FLAG>
<test_wfsTest:NEAR_FID>40</test_wfsTest:NEAR_FID>
<test_wfsTest:NEAR_DIST>185.74736243999999</test_wfsTest:NEAR_DIST>
<test_wfsTest:Shape>
<gml:Point>
<gml:pos>39.906189088000019 116.38803663600004</gml:pos>
</gml:Point>
</test_wfsTest:Shape>
</test_wfsTest:sde_cities>
</gml:featureMember>
</wfs:FeatureCollection>
接着,我想删掉这个对象,就要使用Transaction操作。在ArcGISServer 中,执行删除之前还需要lockId属性,因此还需要通过GetFeatureWithLock 操作获取一个锁:
http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer?
request=getfeaturewithlock&
typename=test_wfsTest:sde_cities&
filter=(
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>CITY_NAME</ogc:PropertyName>
<ogc:Literal>Beijing</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
)
这个操作返回lockId值为"{CEBC222E-00AD-49F5-A0E9-9F4CB98EE07E}",接下来,我们通过一个POST请求对这个对象进行删除,请求体内容如下:
<wfs:Transaction version="1.1.0" service="WFS"
xmlns="http://www.someserver.com/myns"
xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:LockId>{CEBC222E-00AD-49F5-A0E9-9F4CB98EE07E}</wfs:LockId>
<wfs:Delete typeName="test_wfsTest:sde_cities">
<ogc:Filter>
<ogc:GmlObjectId gml:id="F3__474" />
</ogc:Filter>
</wfs:Delete>
</wfs:Transaction>
删除成功后将会返回如下的结果:
<wfs:TransactionResponse version='1.1.0'
xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:gml='http://www.opengis.net/gml'
xmlns:ogc='http://www.opengis.net/ogc' xmlns:wfs='http://www.opengis.net/wfs'>
<wfs:TransactionSummary>
<wfs:totalDeleted>1</wfs:totalDeleted>
</wfs:TransactionSummary>
</wfs:TransactionResponse>
我们也可以在其它的客户端中直接加载这个WFS服务,比如使用uDig:
图20uDig中加载ArcGISServer发布的WFS服务