GetRecords 请求 | 
GetRecords 操作遵循 HTTP 协议,用户终端采用 KVP 编码格式向服务端提交请求,主要请求参数如下:
表1 GetRecords 操作请求主要参数
| 请求参数 | 是否必需 | 描述 | 
| SERVICE=CSW | 
 是  | 
 服务类型。 请求 CSW 服务,请求类型需要设为“CSW”。  | 
| REQUEST=GetRecords | 
 是  | 
 请求操作的名称。 请求 GetRecords 操作,请求名称需要设为“GetRecords”。  | 
| VERSION=version | 
 是  | 
 服务支持的版本号。 服务的版本号,需设为“2.0.2”。  | 
| 
 NAMESPACE=nameSpace  | 
 否  | 
 指定名空间地址。  | 
| 
 RESULTTYPE=resultType  | 
 否  | 
 请求结果的类型。 值为 results、hits、validate,目前支持 results、hits 类型。  | 
| 
 REQUESTID=requestid  | 
 否  | 
 包含 request 信息唯一标识。  | 
| 
 OUTPUTFORMAT=outputFormat  | 
 否  | 
 输出格式。 用于控制输出格式,默认为 application/xml。  | 
| 
 OUTPUTSCHEMA=outputSchema  | 
 否  | 
 结果所用的结构和格式 默认值为 http://www.opengis.net/cat/csw/2.0.2。  | 
| 
 STARTPOSITION=startPosition  | 
 否  | 
 指定返回结果的起始位置。 默认值为1,意思是在结果集中从第一条记录开始返回给客户端。  | 
| 
 MAXRECORDS=maxRecords  | 
 否  | 
 最大记录条数。 指定从结果中返回的记录最大数值,若符合查询条件的记录数小于该值,则返回符合条件的记录条数。  | 
| 
 TYPENAMES=typeNames  | 
 是  | 
 查询信息模型对象。 例如 csw ogc 的 Record 模型。  | 
| 
 ELEMENTSETNAME=ElementSetName  | 
 否  | 
 返回结果类型。 值可为 brief、summary、full。  | 
| 
 ELEMENTNAME=ElementName  | 
 否  | 
 根据指定字段返回结果。 例如<dc:modified>  | 
| 
 CONSTRAINTLANGUAGE=ConstranintLanguage  | 
 否  | 
 指定查询谓语语言。 例如 ogc:filter1.1.0。  | 
| 
 CONSTRAINT=Constraint  | 
 否  | 
 约束条件。 用于定义查询谓语表述,缺省则返回所有结果,例如查询所有记录中与给定范围相交的记录: <Constraint version="1.1.0"> <ogc:Filter> <ogc:Within> <ogc:PropertyName>ows:BoundingBox</ogc:PropertyName> <gml:Envelope> <gml:lowerCorner>-181 -91</gml:lowerCorner> <gml:upperCorner>181 91</gml:upperCorner> </gml:Envelope> </ogc:Within> </ogc:Filter> </Constraint>  | 
| 
 SORTBY=SortBy  | 
 否  | 
 对查询数据中指定字段进行排序。 例如:<SortBy sortOrder='ASC'>modified</SortBy>  | 
GetRecords 操作 POST 的请求方式如下:
GetRecords 操作遵循 HTTP 协议,用户终端可采用 POST 方式向服务端提交请求,例如,本机 SuperMap iServer CSW 2.0.2 服务启动成功之后,POST 访问 GetRecords 操作的 URI 的地址为: http://localhost:8090/iserver/services.csw?SERVICE=CSW&REQUEST=GetRecords&VERSION=2.0.2 。
查询符合与给定范围相交且 title 字段含“map-world”字符的元数据记录,请求体示例如下:
<?xml version="1.0" encoding="utf-8"?>
<GetRecords service="CSW" version="2.0.2" maxRecords="5" startPosition="1" resultType="results" outputFormat="application/xml" outputSchema="http://www.opengis.net/cat/csw/2.0.2" xmlns="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
<ResponseHandler>ftp://www.myserver.com/pub/MyQuery_Resp.xml</ResponseHandler>
<Query typeNames="Record">
<ElementSetName>SUMMARY</ElementSetName>
<Constraint version="1.1.0">
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsLike wildCard="%" singleChar="_" escapeChar="\">
<ogc:PropertyName>title</ogc:PropertyName>
<ogc:Literal>%map-world%</ogc:Literal>
</ogc:PropertyIsLike>
<ogc:Intersects>
<ogc:PropertyName>ows:BoundingBox</ogc:PropertyName>
<gml:Envelope>
<gml:lowerCorner>14.05 46.46</gml:lowerCorner>
<gml:upperCorner>17.24 48.42</gml:upperCorner>
</gml:Envelope>
</ogc:Intersects>
</ogc:And>
</ogc:Filter>
</Constraint>
</Query>
</GetRecords>
该请求示例的响应结果请参见响应示例。
查询在给定时间范围内的元数据记录,请求体示例如下:
<?xml version="1.0" encoding="utf-8"?>
<GetRecords service="CSW" version="2.0.2" maxRecords="5" startPosition="1" resultType="results" outputFormat="application/xml" outputSchema="http://www.opengis.net/cat/csw/2.0.2" xmlns="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd"> <ResponseHandler>ftp://www.myserver.com/pub/MyQuery_Resp.xml</ResponseHandler>
<Query typeNames="Record">
<ElementSetName>brief</ElementSetName>
<Constraint version="1.1.0">
<ogc:Filter>
<ogc:PropertyIsBetween>
<ogc:PropertyName>modified</ogc:PropertyName>
<ogc:LowerBoundary>
<ogc:Literal>2012-09-01</ogc:Literal>
</ogc:LowerBoundary>
<ogc:UpperBoundary>
<ogc:Literal>2020-09-22</ogc:Literal>
</ogc:UpperBoundary>
</ogc:PropertyIsBetween>
</ogc:Filter>
</Constraint>
</Query>
</GetRecords>
查询 rest 类型的元数据记录,请求体示例如下:
<?xml version="1.0" encoding="utf-8"?>
<GetRecords service="CSW" version="2.0.2" maxRecords="5"
startPosition="1" resultType="results" outputFormat="application/xml"
outputSchema="http://www.opengis.net/cat/csw/2.0.2" xmlns="http://www.opengis.net/cat/csw/2.0.2"
xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
<ResponseHandler>ftp://www.myserver.com/pub/MyQuery_Resp.xml</ResponseHandler>
<Query typeNames="Record">
<ElementSetName>brief</ElementSetName>
<Constraint version="1.1.0">
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>dc:type</ogc:PropertyName>
<ogc:Literal>rest</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</Constraint>
</Query>
</GetRecords>