[GIS] Mapserver WMS HTTP POST requests

getmaphttp-postmapserverpostwms

I have an Mapserver 7.0.4 for WMS GetMap requests currently over GET.
Is it possible to send POST GetMap requests to the mapserver?
I already searched some other topics and the documentation, it seems that WFS supports POST but i have no information about WMS.

I already tried to send some POST requests but all i got back was the template i specified and not the actual image i expected.
(Capabilities says POST is enabled)

But it seems that the Mapserver is indeed processing the POST Body:
In the POST Body i used a modified XML file i found online, if the xml file contains mistakes it gives out an error. So something is definitely going on there.

GET: example URL (which works fine)

http://exampleurl.com/cgi-bin/mapserv?MAP=/etc/mapserver/example.map&LAYERS=Example&SRS=EPSG:4326&VISIBILITY=true&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image/png&BBOX=7,49,8,50&WIDTH=256&HEIGHT=256

POST: XML (Which does not work)

<?xml version="1.0" encoding="utf-8"?>
<ogc:GetMap gml="http://www.opengis.net/gml"
 xmlns:ogc="http://www.opengis.net/ows"
 xmlns:gml="http://www.opengis.net/gml" version="1.3.0" service="WMS">
<StyledLayerDescriptor version="1.0.0">
<NamedLayer>
  <Name>Example</Name>
</NamedLayer>
</StyledLayerDescriptor>
<SRS>EPSG:4326</SRS>
<BoundingBox srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
  <gml:X>7</gml:X>
  <gml:Y>49</gml:Y>
</gml:coord>
<gml:coord>
  <gml:X>8</gml:X>
  <gml:Y>50</gml:Y>
</gml:coord>
</BoundingBox>
<Output>
<Size>
  <Width>256</Width>
  <Height>256</Height>
</Size>
<Format>image/png</Format>
<Transparent>TRUE</Transparent>
</Output>
<Exceptions>application/vnd.ogc.se+xml</Exceptions>
</ogc:GetMap>

If WMS works with POST, has anyone more information about the structure of these XML files and how to build them properly?
The Mapserver documention contains only:

The ability
for MapServer to be able to receive Post requests with XML-encoded information sent in the body of the request has
been added. Also, the ability to generate XML-encoded Post requests for WFS layers has been added.

Best Answer

The schema you need to make reference to for the POST request is: http://schemas.opengis.net/sld/1.1.0/GetMap.xsd

A valid request will look something like:

<?xml version="1.0" encoding="UTF-8"?>
<sld:GetMap xmlns:ows="http://www.opengis.net/ows"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:gml="http://www.opengis.net/gml"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:sch="http://www.ascc.net/xml/schematron"
    xmlns:smil20="http://www.w3.org/2001/SMIL20/"
    xmlns:smil20lang="http://www.w3.org/2001/SMIL20/Language"
    xmlns:wms="http://www.opengis.net/wms"
    xmlns:se="http://www.opengis.net/se"
    xmlns:sld="http://www.opengis.net/sld"
    xmlns:wfs="http://www.opengis.net/wfs"
    xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/sld/1.1.0/GetMap.xsd">
    <sld:StyledLayerDescriptor version="1.1.0">
        <sld:NamedLayer>
            <se:Name>World_EMODnet_EN_250k_Submarine_Volcanoes_points</se:Name>
        </sld:NamedLayer>
    </sld:StyledLayerDescriptor>
    <sld:CRS>EPSG:3413</sld:CRS>
    <sld:BoundingBox>
        <ows:LowerCorner>-3571059.167819473 -4645193.605181879</ows:LowerCorner>
        <ows:UpperCorner>4940480.654283983 546492.5103750005</ows:UpperCorner>
    </sld:BoundingBox>
    <sld:Output>
        <sld:Size>
            <sld:Width>1205</sld:Width>
            <sld:Height>735</sld:Height>
        </sld:Size>
        <wms:Format>image/png</wms:Format>
        <sld:Transparent>true</sld:Transparent>
    </sld:Output>
    <sld:Exceptions>INIMAGE</sld:Exceptions>
</sld:GetMap>
Related Question