在 Web 浏览器中与 WMS 服务进行通信

本主题介绍了在 Web 浏览器中如何使用 URL 参数与 WMS 服务进行通信。

WMS 请求和响应

兼容 WMS 服务器所支持的每种操作的在线资源都是一个 HTTP 统一资源定位器 (URL),所以 WMS 服务可被视为一项表述性状态转移 (REST) 服务。与标准 Web 服务不同,使用 WMS 服务不需要 SOAP 客户端,Web 浏览器是其最简单的客户端。通过发送一个 URL 请求到服务器并在浏览器中查看 XML 文档或图像形式的消息响应,您可以获取 WMS 服务的服务级别元数据、地图图像或要素属性值。

以下是一些 WMS 服务所支持的每项操作的请求和响应的示例。

GetCapabilities

请求

http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?version=1.3.0&request=GetCapabilities&service=WMS

XML 响应

<WMS_Capabilities version="1.3.0" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.esri.com/wms http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?version=1.3.0&service=WMS&request=GetSchemaExtension">
 <Service>
  <Name>WMS</Name>
  <Title>Specialty/ESRI_StatesCitiesRivers_USA</Title>
  <Abstract>WMS</Abstract>
  <KeywordList>
   <Keyword></Keyword>
  </KeywordList>
  <OnlineResource xlink:type="simple" xlink:href="http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer"/>
  <ContactInformation>
   <ContactPersonPrimary>
    <ContactPerson></ContactPerson>
    <ContactOrganization></ContactOrganization>
   </ContactPersonPrimary>
    <ContactPosition></ContactPosition>
    <ContactAddress>
     <AddressType></AddressType>
     <Address></Address>
     <City></City>
     <StateOrProvince></StateOrProvince>
     <PostCode></PostCode>
     <Country></Country>
    </ContactAddress>
    <ContactVoiceTelephone></ContactVoiceTelephone>
    <ContactFacsimileTelephone></ContactFacsimileTelephone>
    <ContactElectronicMailAddress></ContactElectronicMailAddress>
  </ContactInformation>
  <Fees></Fees>
  <AccessConstraints></AccessConstraints>
  <MaxWidth>2048</MaxWidth>
  <MaxHeight>2048</MaxHeight>
 </Service>
 <Capability>
  <Request>
   <GetCapabilities>
    <Format>application/vnd.ogc.wms_xml</Format>
    <Format>text/xml</Format>
    <DCPType>
     <HTTP>
      <Get>
       <OnlineResource xlink:type="simple" xlink:href="http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer"/>
      </Get>
     </HTTP>
    </DCPType>
   </GetCapabilities>
   <GetMap>
    <Format>image/bmp</Format>
    <Format>image/jpeg</Format>
    <Format>image/tiff</Format>
    <Format>image/png</Format>
    <Format>image/png8</Format>
    <Format>image/png24</Format>
    <Format>image/png32</Format>
    <Format>image/gif</Format>
    <Format>image/svg+xml</Format>
    <DCPType>
     <HTTP>
      <Get>
       <OnlineResource xlink:type="simple" xlink:href="http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer"/>
      </Get>
     </HTTP>
    </DCPType>
   </GetMap>
   <GetFeatureInfo>
    <Format>application/vnd.esri.wms_raw_xml</Format>
    <Format>application/vnd.esri.wms_featureinfo_xml</Format>
    <Format>application/vnd.ogc.wms_xml</Format>
    <Format>text/xml</Format>
    <Format>text/html</Format>
    <Format>text/plain</Format>
    <DCPType>
     <HTTP>
      <Get>
       <OnlineResource xlink:type="simple" xlink:href="http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer"/>
      </Get>
     </HTTP>
    </DCPType>
   </GetFeatureInfo>
   <esri_wms:GetStyles>
    <Format>application/vnd.ogc.sld+xml</Format>
    <DCPType>
     <HTTP>
      <Get>
       <OnlineResource xlink:type="simple" xlink:href="http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer"/>
      </Get>
     </HTTP>
    </DCPType>
   </esri_wms:GetStyles>
  </Request>
  <Exception>
   <Format>application/vnd.ogc.se_xml</Format>
   <Format>application/vnd.ogc.se_inimage</Format>
   <Format>application/vnd.ogc.se_blank</Format>
   <Format>text/xml</Format>
   <Format>XML</Format>
  </Exception>
  <Layer>
   <Title>Layers</Title>
   <CRS>CRS:84</CRS>
   <CRS>EPSG:4326</CRS>
   <EX_GeographicBoundingBox>
    <westBoundLongitude>-125.192865</westBoundLongitude>
    <eastBoundLongitude>-66.105824</eastBoundLongitude>
    <southBoundLatitude>19.416377</southBoundLatitude>
    <northBoundLatitude>54.318281</northBoundLatitude>
   </EX_GeographicBoundingBox>
   <BoundingBox CRS="CRS:84" minx="-125.192865" miny="19.416377" maxx="-66.105824" maxy="54.318281"/>
   <BoundingBox CRS="EPSG:4326" minx="19.416377" miny="-125.192865" maxx="54.318281" maxy="-66.105824"/>
   <Layer queryable="1">
    <Name>0</Name>
    <Title>States</Title>
    <Abstract>States</Abstract>
    <CRS>CRS:84</CRS>
    <CRS>EPSG:4326</CRS>
    <EX_GeographicBoundingBox>
     <westBoundLongitude>-178.217598</westBoundLongitude>
     <eastBoundLongitude>-66.969271</eastBoundLongitude>
     <southBoundLatitude>18.924782</southBoundLatitude>
     <northBoundLatitude>71.406235</northBoundLatitude>
    </EX_GeographicBoundingBox>
    <BoundingBox CRS="CRS:84" minx="-178.217598" miny="18.924782" maxx="-66.969271" maxy="71.406235"/>
    <BoundingBox CRS="EPSG:4326" minx="18.924782" miny="-178.217598" maxx="71.406235" maxy="-66.969271"/>
    <Style>
     <Name>default</Name>
     <Title>0</Title>
     <LegendURL width="76" height="16">
      <Format>image/png</Format>
      <OnlineResource xlink:href="http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=0" xlink:type="simple"/>
     </LegendURL>
    </Style>
   </Layer>
   <Layer queryable="1">
    <Name>1</Name>
    <Title>Rivers</Title>
    <Abstract>Rivers</Abstract>
    <CRS>CRS:84</CRS>
    <CRS>EPSG:4326</CRS>
    <EX_GeographicBoundingBox>
     <westBoundLongitude>-164.765831</westBoundLongitude>
     <eastBoundLongitude>-67.790980</eastBoundLongitude>
     <southBoundLatitude>25.845557</southBoundLatitude>
     <northBoundLatitude>70.409756</northBoundLatitude>
    </EX_GeographicBoundingBox>
    <BoundingBox CRS="CRS:84" minx="-164.765831" miny="25.845557" maxx="-67.790980" maxy="70.409756"/>
    <BoundingBox CRS="EPSG:4326" minx="25.845557" miny="-164.765831" maxx="70.409756" maxy="-67.790980"/>
    <Style>
     <Name>default</Name>
     <Title>1</Title>
     <LegendURL width="76" height="16">
      <Format>image/png</Format>
      <OnlineResource xlink:href="http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=1" xlink:type="simple"/>
     </LegendURL>
    </Style>
   </Layer>
   <Layer queryable="1">
    <Name>2</Name>
    <Title>Cities</Title>
    <Abstract>Cities</Abstract>
    <CRS>CRS:84</CRS>
    <CRS>EPSG:4326</CRS>
    <EX_GeographicBoundingBox>
     <westBoundLongitude>-158.064606</westBoundLongitude>
     <eastBoundLongitude>-67.986769</eastBoundLongitude>
     <southBoundLatitude>19.696150</southBoundLatitude>
     <northBoundLatitude>64.869104</northBoundLatitude>
    </EX_GeographicBoundingBox>
    <BoundingBox CRS="CRS:84" minx="-158.064606" miny="19.696150" maxx="-67.986769" maxy="64.869104"/>
    <BoundingBox CRS="EPSG:4326" minx="19.696150" miny="-158.064606" maxx="64.869104" maxy="-67.986769"/>
    <Style>
     <Name>default</Name>
     <Title>2</Title>
     <LegendURL width="72" height="16">
      <Format>image/png</Format>
      <OnlineResource xlink:href="http://sampleserver1a.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=2" xlink:type="simple"/>
     </LegendURL>
    </Style>
   </Layer>
  </Layer>
 </Capability>
</WMS_Capabilities>

镶嵌数据集中的 GetMap

对于源于镶嵌数据集的 WMS 服务,可以添加 TIMEIMAGES 参数。

时间

TIME - 通过指定时间实例或时间范围来支持时间查询。格式可为 YYYYMMDDHHMMSS、YYYYMMDD、YYYYMM 或 YYYY。

TIME=1999(时间为 1999 年)

请求

http://server_name/arcgis/services/service_name/ImageServer/WMSServer?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&LAYERS=0&STYLES=&FORMAT=image/png&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&CRS=EPSG:4326&BBOX=17.9995833333334,-161.000416666667,23.0004166666666,-153.999583333333&WIDTH=981&HEIGHT=826&TIME=1999

TIME=1980/2010(时间为 1980 年至 2010 年)

请求

http://server_name/arcgis/services/service_name/ImageServer/WMSServer?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&LAYERS=0&STYLES=&FORMAT=image/png&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&CRS=EPSG:4326&BBOX=17.9995833333334,-161.000416666667,23.0004166666666,-153.999583333333&WIDTH=981&HEIGHT=826&TIME=1980/2010

TIME=1999-12-31T14:30:30/2000-01-01T14:30:30

请求

http://server_name/arcgis/services/service_name/ImageServer/WMSServer?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&LAYERS=0&STYLES=&FORMAT=image/png&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&CRS=EPSG:4326&BBOX=17.9995833333334,-161.000416666667,23.0004166666666,-153.999583333333&WIDTH=981&HEIGHT=826&TIME=1999-12-31T14:30:30/2000-01-01T14:30:30

图像/影像

IMAGE - 支持各个栅格的查询

请求

http://server_name/arcgis/services/service_name/ImageServer/WMSServer?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&LAYERS=0&STYLES=&FORMAT=image/png&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&CRS=EPSG:4326&BBOX=17.9995833333334,-161.000416666667,23.0004166666666,-153.999583333333&WIDTH=981&HEIGHT=826&images=1

IMAGES=1,2(其中数字表示影像服务目录表的对象 ID)

请求

http://server_name/arcgis/services/service_name/ImageServer/WMSServer?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&LAYERS=0&STYLES=&FORMAT=image/png&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&CRS=EPSG:4326&BBOX=17.9995833333334,-161.000416666667,23.0004166666666,-153.999583333333&WIDTH=981&HEIGHT=826&images=1,2

GetFeatureInfo

请求

http://sampleserver1.arcgisonline.com/arcgis/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?version=1.1.1&request=GetFeatureInfo&layers=0&styles=default&SRS=EPSG:4326&bbox=-125.192865,11.2289864971264,-66.105824,62.5056715028736&width=1044&height=906&format=text/html&X=500&Y=400&query_layers=0

XML 响应

<FeatureInfoResponse>
 <FIELDS FID="14" Shape="Null" AREA="77330.258" STATE_NAME="Nebraska" STATE_FIPS="31" SUB_REGION="W N Cen" 
  STATE_ABBR="NE" POP1990="1578385" POP1999="1671251" POP90_SQMI="20" HOUSEHOLDS="602363" MALES="769439" 
  FEMALES="808946" WHITE="1480558" BLACK="57404" AMERI_ES="12410" ASIAN_PI="12422" OTHER="15591" 
  HISPANIC="36969" AGE_UNDER5="119606" AGE_5_17="309406" AGE_18_29="281105" AGE_30_49="441470" 
  AGE_50_64="203730" AGE_65_UP="223068" NEVERMARRY="295873" MARRIED="719288" SEPARATED="13552" 
  WIDOWED="96052" DIVORCED="90230" HSEHLD_1_M="63686" HSEHLD_1_F="95985" MARHH_CHD="171428" 
  MARHH_NO_C="179086" MHH_CHILD="7603" FHH_CHILD="34583" HSE_UNITS="660621" VACANT="58258" 
  OWNER_OCC="400394" RENTER_OCC="201969" MEDIAN_VAL="50400" MEDIANRENT="282" UNITS_1DET="479124" 
  UNITS_1ATT="15767" UNITS2="18369" UNITS3_9="46246" UNITS10_49="49402" UNITS50_UP="9656" 
  MOBILEHOME="37046" NO_FARMS87="60502" AVG_SIZE87="749" CROP_ACR87="23320162" AVG_SALE87="110197"/>
</FeatureInfoResponse>

GetStyles

请求

http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StateCityHighway_USA/MapServer/WMSServer?version=1.3.0&request=GetStyles&layers=0,1,2

XML 响应

<sld:StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
 <!-- layer "0" -->
 <sld:NamedLayer>
  <sld:Name>0</sld:Name>
  <!-- NamedStyle -->
  <sld:NamedStyle>
   <sld:Name>default</sld:Name>
  </sld:NamedStyle>
  <!-- UserStyle -->
 </sld:NamedLayer>
 <!-- layer "1" -->
 <sld:NamedLayer>
  <sld:Name>1</sld:Name>
  <!-- NamedStyle -->
  <sld:NamedStyle>
   <sld:Name>default</sld:Name>
  </sld:NamedStyle>
  <!-- UserStyle -->
 </sld:NamedLayer>
 <!-- layer "2" -->
 <sld:NamedLayer>
  <sld:Name>2</sld:Name>
  <!-- NamedStyle -->
  <sld:NamedStyle>
   <sld:Name>default</sld:Name>
  </sld:NamedStyle>
  <!-- UserStyle -->
 </sld:NamedLayer>
</sld:StyledLayerDescriptor>

GetLegendGraphic

请求

http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?version=1.1.1&request=GetLegendGraphic&layer=0&style=default&format=image/png&width=95&height=65

响应图例图形

WMS GetLegendGraphic 图例图形响应
注注:

许多情况下,Web 浏览器可能并不是首选的 WMS 客户端,但对于 WMS 服务器和客户端之间的通信,Web 浏览器却始终是一个很好的追踪和调试工具。

WMS 请求参数

OGC 网络地图服务规范定义了一份可用于每项 WMS 操作的完整请求参数列表。有关 OGC WMS 执行规范的不同版本,请参见以下链接:

版本 1.3.0

版本 1.1.1

版本 1.1.0

版本 1.0.0

下表列出了可用于执行 WMS 的所有请求参数,这只是规范所定义的参数的一个子集。

WMS GetCapabilities 请求 URL 的参数

必选/可选

默认值

说明

VERSION/WMTVER

可选

1.3.0(9.3 及以上)

1.1.1 (9.2)

请求版本。只在 WMS 1.0.0 中使用 WMTVER;其他情况下使用 VERSION

SERVICE

必选

N/A

服务类型。必须设置为 WMS。该参数在 WMS 1.0.0 中不可用。

REQUEST

必选

N/A

请求名称。必须设置为 GetCapabilities。对于 WMS 1.0.0,则必须设置为 capabilities

FORMAT

可选

text/xml(9.3 及以上)

服务元数据的输出格式。仅在 WMS 1.3.0 中可用(例如 application/vnd.ogc.wms_xmltext/plaintext/html)。

WMS GetMap 请求 URL 的参数

必选/可选

默认值

说明

VERSION/WMTVER

必选

N/A

请求版本。只在 WMS 1.0.0 中使用 WMTVER;其他情况下使用 VERSION

REQUEST

必选

N/A

请求名称。必须设置为 GetMap。对于 WMS 1.0.0,则必须设置为 map

LAYERS

必选

N/A

一个或多个地图图层的逗号分隔列表(例如 0,1,2layer1,layer2)。

STYLES

必选

N/A

一种或多种样式的逗号分隔列表,每个请求图层一种样式(例如 0,1,2style1,style2)。

CRS/SRS

必选

N/A

坐标参照系统。CRS 仅可在 WMS 1.3.0 中使用;其他情况下使用 SRS(例如 EPSG:4326EPSG:4269)。

BBOX

必选

N/A

以 CRS/SRS 为单位的(左下和右上)边框角(例如 -180,-90,180,90)。

WIDTH

必选

N/A

以像素为单位的地图图片宽度(例如 1024)。

HEIGHT

必选

N/A

以像素为单位的地图图片高度(例如 768)。

FORMAT

必选

N/A

地图的输出格式(例如 image/pngimage/jpegimage/svg+xml)。

TRANSPARENT

可选

False

确定背景是否透明(分别为 TrueFalse)。

BGCOLOR

可选

0xFFFFFF

十六进制 RGB 地图背景色(例如 0xFFFFFFFFFFFF)。

SLD

可选

""

样式化图层描述符 XML 文件的 URL。

SLD_BODY

可选

""

样式化图层描述符文件的 XML 正文。

TIME

可选

""

请求图层的时间值。

EXCEPTIONS

可选

text/xml (WMS 1.3.0)

application/vnd.ogc.se_xml(WMS 1.1.1 和 WMS 1.1.0)

application/vnd.ogc.inimage (WMS 1.0.0)

报告异常应使用的格式(例如 text/xmltext/html)。

WMS GetFeatureInfo 请求 URL 的参数

必选/可选

默认值

说明

VERSION/WMTVER

必选

N/A

请求版本。只在 WMS 1.0.0 中使用 WMTVER;其他情况下使用 VERSION

REQUEST

必选

N/A

请求名称。必须设置为 GetFeatureInfo。对于 WMS 1.0.0,则必须设置为 feature_info

地图请求部分

必选

N/A

生成地图所需信息的 GetMap 请求参数的部分副本。

QUERY_LAYERS

必选

N/A

一个或多个待查询地图图层的逗号分隔列表(例如 0,1,2layer1,layer2)。

INFO_FORMAT

必选 (WMS 1.3.0)

可选(WMS 1.1.1、1.1.0 和 1.0.0)

无效 (WMS 1.3.0)

text/xml(WMS 1.1.1、1.1.0 和 1.0.0)

要素信息的返回格式(例如 text/xmltext/html)。

I/X

必选

N/A

要素在地图坐标系中以像素为单位的 X 坐标(例如 100)。对于 WMS 1.3.0,使用 I;其他情况下使用 X

J/Y

必选

N/A

要素在地图坐标系中以像素为单位的 Y 坐标(例如 100)。对于 WMS 1.3.0,使用 J;其他情况下使用 Y

TIME

可选

""

请求图层的时间值。

EXCEPTIONS

可选

text/xml (WMS 1.3.0)

application/vnd.ogc.se_xml(WMS 1.1.1 和 WMS 1.1.0)

application/vnd.ogc.inimage (WMS 1.0.0)

报告异常应使用的格式(例如 text/xmltext/html)。

WMS GetStyles 请求的参数

必选/可选

默认值

说明

VERSION

必选

1.3.0(9.3 及以上)

1.1.1 (9.2)

OGC 接口要求的版本。

REQUEST

必选

N/A

请求名称。必须设置为 GetStyles

LAYERS

必选

N/A

要检索样式描述的指定图层的逗号分隔列表。

SLDVER

可选

1.0.0 (10.0)

为 SLD 文档请求的 SLD 版本。仅支持 1.0.0 版本。

WMS GetLegendGraphic 请求的参数

必选/可选

默认值

说明

VERSION

必选

1.3.0(9.3 及以上)

1.1.1 (9.2)

OGC 接口要求的版本。

REQUEST

必选

N/A

请求名称。必须设置为 GetLegendGraphic

LAYER

必选

N/A

要生成图例图形的图层。

STYLE

可选

默认

要生成图例图形的图层的样式。如果不存在,将选择默认样式。该样式可以是任何可用于图层的有效样式,包括非 SLD 内部定义样式。

RULE

可选

""

要用于生成图例图形的样式规则(如果适用)。样式具有多条规则但未选择任何特定规则时,地图服务负责生成表示所有样式规则的图形。

SLD

可选

""

指定 SLD 文档的引用。其工作原理与 WMS GetMap 操作的 SLD= 参数相同。

SLD_BODY

可选

""

允许 HTTP GET 请求直接包括 SLD 文档。其工作原理与 WMS GetMap 操作的 SLD_BODY 参数相同。

FORMAT

可选

image/png (png24)

用于返回图例的 MIME 文件格式类型。所允许的值与 WMS GetMap 请求的 FORMAT= 参数相同。

WIDTH

可选

取决于具体的图例图像

对返回的图形提供以像素为单位的宽度提示。

HEIGHT

可选

取决于具体的图例图像

对返回的图形提供以像素为单位的高度提示。

EXCEPTIONS

可选

text/xml (WMS 1.3.0)

application/vnd.ogc.se_xml(WMS 1.1.1 和 WMS 1.1.0)

application/vnd.ogc.inimage (WMS 1.0.0)

用于返回异常的 MIME 格式类型。所允许的值与 WMS GetMap 请求的 EXCEPTIONS= 参数相同。

9/15/2013