[mapserver-users] OwS request - how to use POST rather than GET

Stuart Eve stuarteve at gmail.com
Mon May 28 03:50:03 PDT 2012


Dear all

I am attempting to load a Mapserver WFS layer via the Openlayers WFS Protocol.

I use a PHP Mapscript wrapper on my WFS server to handle the OwS requests - however, it only seems to respond to GET requests and not POST requests. Openlayers sends the WFS request using POST (and I think it is a bit of an encoded request so may need decoding on the mapserver end). The result of this being that my mapscript wrapper doesn't respond. 

Therefore I see two options 

1. getting mapscript to read the POST request (as well as other GET requests)

2. getting Openlayers to send the WFS request as GET (although this become a problem with lots of filters, etc.)

I wonder if someone on the list could point me in the right direction?

Many thanks

Stuart

Here is my mapscript code:

=====

$request = ms_newowsrequestobj();
$buffer = FALSE;

//now we need to set up the request parameters and loop through them adding them to the request object
foreach ($_REQUEST as $key =>$value)    {
    $request->setParameter($key,$value);
}
ms_ioinstallstdouttobuffer();

//this mapfile path is set in config/settings
if ($request->getValueByName('SERVICE') == 'WMS') {
    $oMap = ms_newMapobj("$wms_map");
}
if ($request->getValueByName('SERVICE') == 'WFS') {
    $oMap = ms_newMapobj("$wfs_map");
}
$oMap->owsdispatch($request);
$contenttype = ms_iostripstdoutbuffercontenttype();

..etc

====

here is what is sent via POST by Openlayers (as retrieved from FireBug):

====

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Query typeName="settlements"/></wfs:GetFeature>

====

And here is my Openlayers call:

====

  var settlements = new OpenLayers.Layer.Vector("WFS", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                protocol: new OpenLayers.Protocol.WFS({
                    url:  "http://localhost/path/to/my/mapscript.php?",
                    featureType: "settlements",
                    featurePrefix: "ms",
                    version: "1.0.0",
                }),
            });





More information about the mapserver-users mailing list