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

Donald Kerr donald.kerr at dkerr.co.uk
Wed Dec 8 15:13:51 PST 2010


Apologies for cross-posting on two lists but I'm not sure who may be better
placed to answer this one.

Basically, the setup is MapServer and OpenLayers. I have two pages, both are
exactly the same with the exception that one calls mapserver on Port 81
(Apache) and the other calls Mapserver on Port 81 via an asp page using
MSXML2.ServerXMLHTTP to hide the mapfile string and its location. This
method is documented here: http://mapserver.org/ogc/wms_server.html (3.On
IIS servers (Windows), you can use the following ASP script ..... etc).

OpenLayers.Layer.WFS works fine on both setups as this uses GET requests but
this will be deprecated in version 3, see here:
http://dev.openlayers.org/docs/files/OpenLayers/Layer/WFS-js.html.

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.

The method using MSXML2.ServerXMLHTTP (see the first link above) converts
everything to GET but I have changed the code to use post as follows:

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

Select Case Request.ServerVariables("REQUEST_METHOD")
	Case "GET"
		strRequest = Request.QueryString
		MapserverUrl = "<url>mapserv.exe?MAP=<map file>.map&" &
strRequest
		xmlhttp.open "GET", MapServerURL, False
		xmlhttp.send '
	Case "POST"
		strRequest = Request.Form
		MapserverUrl = "<url>mapserv.exe?MAP=<map file>"
		xmlhttp.Open "POST", MapserverUrl, False

		Set SendDoc = server.createobject("Microsoft.XMLDOM") 
		SendDoc.ValidateOnParse= True 
		SendDoc.LoadXML(strRequest) 

		'Various header types (All tried at different times)
		'xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
		'xmlhttp.setRequestHeader "Content-Type", "application/xml"
//OpenLayers
		'xmlhttp.setRequestHeader "Content-Type","text/xml"

		'Two ways of sending xml (Both tried)
		'xmlhttp.send strRequest
		xmlhttp.send Sendoc
End Select

Response.ContentType = xmlhttp.getResponseHeader("content-type")
Response.BinaryWrite xmlhttp.responseBody

Set xmlhttp = Nothing
=============================================================

I have tried everything I can think of including setting a variable that
contains the xml within the code above, i.e. it isn't sent from the html
page with the map, to no avail.

The closest I can get to it working is a response (as shown in Firebug) as
follows:

=============================================================
<?xml version='1.0' encoding="ISO-8859-1" ?>
<ServiceExceptionReport version="1.2.0" xmlns="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/ogc
http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
  <ServiceException code="InvalidParameterValue" locator="filter">
msWFSGetFeature(): WFS server error. Invalid or Unsupported FILTER in
GetFeature : <filter ogc="http://www.opengis.net/ogc">
  <bbox>
    <propertyname>msGeometry</propertyname>
    <box gml="http://www.opengis.net/gml"
srsName="EPSG:27700">
      <coordinates decimal="." cs="," ts="
">256643.52324254,664529.16740962
260422.47675746,667280.83259038</coordinates>
    </box>
  </bbox>
</filter>

  </ServiceException>
</ServiceExceptionReport>
=============================================================

The above is using a variable (that contains xml) in the asp file and not
the Request.Form in the code above.

I also get the following when using the Request.Form from the map page:

=============================================================
<?xml version='1.0' encoding="ISO-8859-1" ?>
<ServiceExceptionReport version="1.2.0"
xmlns="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/ogc
http://schemas.opengis.net/wcs/1.0.0/OGC-exception.xsd">
  <ServiceException>msWCSParseRequest(): WCS server error. WCS Server does
not support XML POST requests, please use KVP.
  </ServiceException>
</ServiceExceptionReport>
=============================================================

What I want to get using MSXML2.ServerXMLHTTP is the same response as I get
using the method that calls MapServer on port 81 i.e. I should get valid GML
without the geometry.

OpenLayers uses MSXML2.ServerXMLHTTP for the POST and all I am really trying
to do is pass that request through another MSXML2.ServerXMLHTTP to
MapServer. This is be quite basic I think but I have spent hours on the
problem and have visited everything that I possibly can on Google without
success. I suppose that someone who knows about MSXML2.ServerXMLHTTP might
be the person to ask but I am hopeful that someone in the MapServer or the
OpenLayers community might have cracked this problem.

I'm stumped! HELP PLEASE!!!

Many thanks.

Regards,

Donald Kerr

P.S. Please don't tell me to use Apache directly! I know that this may be a
solution that would work but I want to solve this one and I want to have IIS
on port 80 for other stuff and MS4w on Port 81 for maps.




More information about the MapServer-users mailing list