[Mapserver-dev] WFS interoperability issues

bartvde at xs4all.nl bartvde at xs4all.nl
Fri Feb 13 03:55:00 EST 2004


Hi Rob,

this is the request I am using with Python, but perhaps my request is not
completely OGC standardised, but it works for the ArcIMS WFS as well.

import httplib, urllib, string, base64, time

# 1) set variable for request to be posted
request="""
<GetFeature service="WFS" version="1.0.0"
  maxFeatures="10"
  xmlns="http://www.opengis.net/wfs"
  xmlns:gml="http://www.opengis.net/gml"
  xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://schemas.opengis.net/wfs/1.0.0 WFS-basic.xsd">
  <Query typeName="Gemeentes">
    <ogc:Filter>
      <ogc:BBOX>
      	<PropertyName>MS_GEOMETRY</PropertyName>
      	<gml:Box><gml:coordinates>139000,469000
140000,470000</gml:coordinates></gml:Box>
      </ogc:BBOX>
    </ogc:Filter>
  </Query>
</GetFeature>
"""

# 2) set WFS servername and hostname
server="/cgi-bin/mapserv.exe?map=/ms4w/apps/general/map/gemeentes.map"
hostname="myserver:1111"

# 3) execute the request
h = httplib.HTTP(hostname)
h.putrequest("POST", server)
h.putheader("Content-type", "text/xml")
h.putheader("Content-length", "%d" % len(request))
h.putheader("Accept", "text/xml")
h.putheader('Host', hostname)
h.endheaders()
h.send(request)
reply, msg, hdrs = h.getreply()

# 4) print the response
print h.getfile().read()

Best regards,
Bart

> Thanks very much Bart
>
>> I am using a different binary version and the POST request works
>> perfectly.
>
> For me it responds with (an improperly formatted) error message:
>
>     "    POST body is short"
>
> possibly because I do not set the Content-length property in the POST.
> It works on every other HTTP POST base Web service  implementation I've
> seen however. (And no - I really dont want to serialise my XML again
> just to see how big it is)
>
>>
>> You can download a CVS binary from 2 February 2004 at:
>>
>> http://www.xs4all.nl/~bartvde/mapserv_41.exe
>
> thanks for this.  Seems to behave the same FYI
>
>>
>> With respect to the MAP file parameter, just use it in the URL to
>> which you post. E.g. in my test I post to:
>> http://myserver/cgi-bin/mapserv.exe?map=/ms4w/apps/general/map/gemeentes.map
>>
>
> To my mind this is rather mixing GET and POST - but I'd be happy to be
> proved wrong
>
> it may be more legal to do this
>
> http://myserver/cgi-bin/mapserv.exe/ms4w/apps/general/map/gemeentes.map
>
>
>




More information about the mapserver-dev mailing list