mapserver recipe - WFS client and service

The Situation

A load of GPS tracks (stored in PostGIS) on one machine, and i wanted to allow people to make annotations over the top of them on another machine. Enough of this moving SQL dumps about; i'll start using the Web Feature Service, WFS, to share data between my mapserver installations.

To connect as a WFS client from mapserver, i added a layer in the mapfile with the following extr properties:

    layer
	...
        connectiontype WFS
        connection "http://locative.us/freemap/map.cgi?"
        status default
        debug true
        type line
        metadata
            "wfs_service" "WFS"
            "wfs_version" "1.0.0"
            "wfs_typename" "gps_tracks"
            "wfs_request_method"    "GET"
        end

To persuade a mapserver to be a WFS server i had to make two edits to the mapfile: one in the web stanza setting config parameters, and another in the layer adding optional WFS metadata.

    web
	...
        metadata
            "wfs_title" "freemap WFS - bristol"
            "wfs_onlineresource" "http://uo.space.frot.org/freemap/map.cgi?service=WFS"
            "wfs_srs" "EPSG:32630"
        end
    end 

For some reason, dump true has to be set for the data your layer to show up via WFS.

    layer 
	...
        metadata
            "wfs_title" "gps_tracks"
        end
	dump true
    end 
    

That's it! This was thankfully easy. You can check out the capabilities of your WFS server by issuing a request like: http://uo.space.frot.org/freemap/map.cgi?service=WFS&request=GetCapabilities
These documents were helpful:

mapscript recipes