[mapserver-users] MSXML2.ServerXMLHTTP - POST not GET- OpenLayers/Mapserver WFS

Donald Kerr donald.kerr at dkerr.co.uk
Thu Dec 9 17:14:25 EST 2010


Here's my solution incorporating the binary read suggestion from Arnd
Wippermann over on users at openlayers.org:

<%
MapServerUrl = "http://127.0.0.1:81/cgi-bin/mapserv.exe"
MapFile = "D:\mymapfilepath\mymapfile.map"

Server.ScriptTimeout = 360

Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

Function BytesToText(strBytes)
	strAsciiText = ""
	lngLength = LenB(strBytes)
	For lngIndex = 1 To lngLength
		lngAsciiCode = AscB(MidB(strBytes, lngIndex, 1))
		strAsciiText = strAsciiText & Chr(lngAsciiCode)
	Next
	BytesToText = strAsciiText
End Function

Select Case Request.ServerVariables("REQUEST_METHOD")
	Case "GET"
		strRequest = Request.QueryString
		xmlhttp.open "GET", MapServerURL & "?MAP=" & MapFile & "&" &
strRequest, False
		xmlhttp.send
		Response.ContentType =
xmlhttp.getResponseHeader("content-type")
		Response.BinaryWrite xmlhttp.responseBody
	Case "POST"
		lngByteSize = Request.TotalBytes
		strRequest  = BytesToText(Request.BinaryRead(lngByteSize))
		xmlhttp.open "POST", MapServerURL & "?MAP=" & MapFile, false
		xmlhttp.setRequestHeader "Content-Type", "application/xml;
charset=UTF-8"
		xmlhttp.send strRequest
		Response.write xmlhttp.responseText
End Select

Set xmlhttp = Nothing
%>

Just set the MapServerUrl and the MapFile constants at the top of the code.
Works for both GETs and POSTs in my setup where the map baselayers are using
OpenLayers.Layer.WMS. I also have OpenLayers.Layer.WFS (uses GET) and
OpenLayers.Layer.Vector with OpenLayers.Protocol.WFS (uses POST). All are
working.

Many thanks.

Regards,

Donald


-----Original Message-----
From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Jeff McKenna
Sent: 09 December 2010 13:09
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] MSXML2.ServerXMLHTTP - POST not GET-
OpenLayers/Mapserver WFS


On 10-12-08 7:13 PM, Donald Kerr wrote:
>
> I am trying to port the setup so that it uses OpenLayers.Layer.Vector 
> with OpenLayers.Protocol.WFS which uses POST as opposed to GET. This 
> works fine with the setup that calls Apache directly on port 81 but 
> does not work using MSXML2.ServerXMLHTTP in the asp page. When I say 
> that it works fine with Apache, it returns valid GML but there's no 
> geometry which, I believe, is sorted in MapServer 5.6.4 - I am using 
> 5.6.3 in the latest MS4W package.
>

Note that MapServer version 5.6.5 is available through the MS4W 
downloads page 
(http://www.maptools.org/ms4w/index.phtml?page=downloads.html).

-jeff



-- 
Jeff McKenna
MapServer Consulting and Training Services http://www.gatewaygeomatics.com/


_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the mapserver-users mailing list