[mapserver-users] minimal wrapper script for OGC services

Kralidis,Tom [Ontario] Tom.Kralidis at ec.gc.ca
Wed Feb 18 08:58:15 EST 2009


Hi: we are deploying MapServer 5.2.1 in a Windows environment, and require the use of a wrapper script to have a prettier url, and to hide the underlying mapfile path.

I tried the ASP example at http://www.mapserver.org/ogc/wms_server.html#more-about-the-online-resource-url, and it works well for GET requests, but not POST requests.

MapServer WFS and SOS support both GET and POST approaches (where POST is the client sending an XML document as the request).

I then thought of using a minimal MapScript WxS wrapper, and this works perfectly with Python:

import mapscript

req = mapscript.OWSRequest()
req.loadParams()
map = mapscript.mapObj('/path/to/config.map')
map.OWSDispatch(req)

Unfortunately, we are bound to either ASP or PHP to deploy the wrapper.

Trying this in PHP:

<?php

dl("php_mapscript.dll");

$request = ms_newowsrequestobj();

$request->loadparams();

ms_ioinstallstdouttobuffer();

$oMap = ms_newMapobj('../../apps/ms_ogc_workshop/sos/config.map');

$oMap->owsdispatch($request);

$contenttype = ms_iostripstdoutbuffercontenttype();

$buffer = ms_iogetstdoutbufferstring();

header('Content-type: $contenttype');
echo $buffer;

ms_ioresethandlers();

?>

Handles GET requests seemingly fine, but when testing with POST, I get the following response:

HTTP/1.1 200 OK
Date: Wed, 18 Feb 2009 13:46:37 GMT
Server: Apache/2.2.10 (Win32)
Connection: close
Content-Type: text/html

POST body is short

As an aside, the PHP e.g. prompts a file download dialog when deployed on a Linux box (?).

I'm using ms4w as the testing environment:

- save PHP file to c:\ms4w\Apache\htdocs\test.php
- go to http://localhost/ms_ogc_workshop/sos/index.html
- in the "server" input text box, point to the PHP script (i.e. http://localhost/test.php)
- click "GetCapabilities" to the request to be POST'd
- click "Send"

Any ideas or suggestions?

Thanks

..Tom



More information about the mapserver-users mailing list