[OpenLayers-Users] Strange behaviourwithOpenLayers.Request.POST and MapServer

David Alda Fernandez de Lezea dalda at ikt.es
Tue Jun 22 08:37:24 EDT 2010


Christopher,

Thanks for your response. I'm trying to understand also how MapServers' WFS works. As far as I know, from my experience, which is not much, whenever I wanted to make a getFeature request from a JavaScript client using a filter I used AJAX Post requests and passing the data of the Filter as an XML string in the method 'xhr.send(params)'. 

>Generally, the "TEMPLATE" error message means that you are not providing enough information for MapServer to determine that the request
>is intended to be a WMS or WFS request. In this case, it looks like you are not including any of the parameters like SERVICE:WFS,
>version strings, etc. in your request URL; It is possible that MapServer can therefore not determine that this is a WFS request

Finally I get some light of what the hell could be an error like "TEMPLATE ....", I didn't found anything about it related to WFS getFeature Requests.

>I don't know WFS well, but my recommendation would be to add additional WFS parameters -- possibly an action, possibly a service, 
>possibly others -- and see if that improves the situation any.

The problem here is that if set to the onlie resource the parameter SERVICE=WFS, then MapServer asks for another parameter, VERSION, and then for another one, REQUEST, and then for another one, TYPENAME, but this is not what I want because I make filters on the fly and I pass them as POST parameter, and also this filters maybe complex and very long, so I think is not possible in my case to do it like that.

The most strange thing is that I can get the data not using the proxy-script, but whenever I pass through the proxy-script, there are problems.

I think that there might be the problem...

Thanks anyway, I'll continue seeking.


Un saludo,
 
··················································································

David Alda Fernández de Lezea
Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y Biodiversidad
 
IKT
Granja Modelo s/n · 01192 · Arkaute (Araba)

··················································································
Tlfnos.: 945-00-32-95                         Fax: 945-00.32.90
··················································································
email: dalda at ikt.es                                web: www.ikt.es
··················································································

-----Mensaje original-----
De: christopher.schmidt at nokia.com [mailto:christopher.schmidt at nokia.com] 
Enviado el: martes, 22 de junio de 2010 14:21
Para: David Alda Fernandez de Lezea
CC: users at openlayers.org
Asunto: Re: [OpenLayers-Users] Strange behaviourwithOpenLayers.Request.POST and MapServer


On Jun 22, 2010, at 3:19 AM, ext David Alda Fernandez de Lezea wrote:

David,

Generally, the "TEMPLATE" error message means that you are not providing enough information for MapServer to determine that the request is intended to be a WMS or WFS request. In this case, it looks like you are not including any of the parameters like SERVICE:WFS, version strings, etc. in your request URL; It is possible that MapServer can therefore not determine that this is a WFS request.

I don't know WFS well, but my recommendation would be to add additional WFS parameters -- possibly an action, possibly a service, possibly others -- and see if that improves the situation any.

Best of luck.

> David,
>
> Thanks for your response. The strange thing is that I've got a TEMPLATE defined at Layer level in MapServer's mapfile:
>
> LAYER
>                        DEBUG 5
>                        NAME "RecintosSigpac"
>                        PROJECTION
>                                "init=epsg:23030"
>                        END
>                        METADATA
>                                "wfs_title" "Recintos Sigpac 2009" ## REQUIRED
>                                "wfs_abstract" "Recintos"
>                                "wfs_name" "RecintosSigpac"
>                                "wfs_geometry_element_name" "MS_GEOMETRY"
>                                "wfs_srs" "EPSG:23030" ## Recommended
>                                "wfs_extent"          "463506.9978541628 4702558.185239193 603185.4988525142 4811754.780732273"
>                                "gml_featureid" "gid" ## REQUIRED
>                                "gml_include_items"     "all"
>                        END
>                        TYPE POLYGON
>
>                        CONNECTIONTYPE oraclespatial
>                        CONNECTION "admcarto/admcarto at ORA10GEX"
>
>                        DATA "GEOMETRY FROM (SELECT * FROM 
> GT_SIGPAC_REC_2010_ED50) USING UNIQUE gid SRID 82337" #todo el sigpac
>
>                        DUMP TRUE ## REQUIRED
>
>                        CLASS
>                                NAME "Recintos"
>                                STYLE
>                                        OUTLINECOLOR 255 255 255
>                                END
>                                TEMPLATE "ms_template.html"
>                        END
>
>
>                        STATUS ON
>                END # Layer
>
> The thing is that with the following instruction:
>
> OpenLayers.Request.POST({url: this.onlineResource, callback: 
> callbackFunction, data: filter});
>
> Having this.onlineResource = 
> http://192.168.1.65/cgi-bin/mapserv.exe?map=../htdocs/MFD/ejemplo_wfs.
> map&
> data = filter for getFeature Request
>
> I don't have any troubles, I get the features correctly. But when I try to make the same request over the proxy, that's when then troubles come:
>
> OpenLayers.Request.POST({url: networkSettings.proxyURL, callback: 
> callbackFunction, params: {url: this.onlineResource, method: "POST", 
> data: filter}});
>
> Having:
>
> networkSettings.proxyURL = http://192.168.1.65/webproxy.php?
> filter = filter for getFeature Request
>
> I've tried, also, to use the parameter proxy but without success, in fact, I don't get anything, no error, no response, nothing at all.
>
> Apache log:
>
> 192.168.1.65 - - [22/Jun/2010:09:13:47 +0200] "POST 
> /webproxy.php?http%3A%2F%2F192.168.1.65%2Fcgi-bin%2Fmapserv.exe%3Fmap%
> 3D..%2Fhtdocs%2FMFD%2Fejemplo_wfs.map%26%26url%3Dhttp%253A%252F%252F19
> 2.168.1.65%252Fcgi-bin%252Fmapserv.exe%253Fmap%253D..%252Fhtdocs%252FM
> FD%252Fejemplo_wfs.map%2526%26method%3DPOST%26data%3D%253C%253Fxml%252
> 0version%253D%25221.0%2522%2520%253F%253E%253Cwfs%253AGetFeature%2520s
> ervice%253D%2522WFS%2522%2520version%253D%25221.1.0%2522%2520outputFor
> mat%253D%2522text%252Fxml%253B%2520subtype%253Dgml%252F3.1.1%2522%2520
> xmlns%253Awfs%253D%2522http%253A%252F%252Fwww.opengis.net%252Fwfs%2522
> %2520xmlns%253Aogc%253D%2522http%253A%252F%252Fwww.opengis.net%252Fogc
> %2522%2520xmlns%253Axsi%253D%2522http%253A%252F%252Fwww.w3.org%252F200
> 1%252FXMLSchema-instance%2522%2520xsi%253AschemaLocation%253D%2522http
> %253A%252F%252Fwww.opengis.net%252Fwfs%2520..%252Fwfs%252F1.1.0%252FWF
> S.xsd%2522%253E%253Cwfs%253AQuery%2520typeName%253D%2522RecintosSigpac
> %2522%253E%253CPropertyName%253EmsGeometry%253C%252FPropertyName%253E%
> 250A%2509%2509%2509%2509%2520%253CFilter%253E%250A%2509%2509%2509%2509
> %2509%253COr%253E%250A%2509%2509%2509%2509%2509%2509%253CAnd%253E%250A
> %2509%2509%2509%2509%2509%2509%2509%253CPropertyIsEqualTo%253E%250A%25
> 09%2509%2509%2509%2509%2509%2509%2509%253CPropertyName%253EPROVINCIA%2
> 53C%252FPropertyName%253E%253CLiteral%253E1%253C%252FLiteral%253E%250A
> %2509%2509%2509%2509%2509%2509%2509%253C%252FPropertyIsEqualTo%253E%25
> 0A%2509%2509%2509%2509%2509%2509%2509%253CPropertyIsEqualTo%253E%250A%
> 2509%2509%2509%2509%2509%2509%2509%2509%253CPropertyName%253EMUNICIPIO
> %253C%252FPropertyName%253E%253CLiteral%253E1%253C%252FLiteral%253E%25
> 0A%2509%2509%2509%2509%2509%2509%2509%253C%252FPropertyIsEqualTo%253E%
> 250A%2509%2509%2509%2509%2509%2509%2509%253CPropertyIsEqualTo%253E%250
> A%2509%2509%2509%2509%2509%2509%2509%2509%253CPropertyName%253EPOLIGON
> O%253C%252FPropertyName%253E%253CLiteral%253E1%253C%252FLiteral%253E%2
> 50A%2509%2509%2509%2509%2509%2509%2509%253C%252FPropertyIsEqualTo%253E
> %250A%2509%2509%2509%2509%2509%2509%2509%253CPropertyIsEqualTo%253E%25
> 0A%2509%2509%2509%2509%2509%2509%2509%2509%253CPropertyName%253EPARCEL
> A%253C%252FPropertyName%253E%253CLiteral%253E1%253C%252FLiteral%253E%2
> 50A%2509%2509%2509%2509%2509%2509%2509%253C%252FPropertyIsEqualTo%253E
> %250A%2509%2509%2509%2509%2509%2509%2509%253CPropertyIsEqualTo%253E%25
> 0A%2509%2509%2509%2509%2509%2509%2509%2509%253CPropertyName%253ERECINT
> O%253C%252FPropertyName%253E%253CLiteral%253E1%253C%252FLiteral%253E%2
> 50A%2509%2509%2509%2509%2509%2509%2509%253C%252FPropertyIsEqualTo%253E
> %250A%2509%2509%2509%2509%2509%2509%253C%252FAnd%253E%250A%2509%2509%2
> 509%2509%2509%2509%253CAnd%253E%250A%2509%2509%2509%2509%2509%2509%250
> 9%253CPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%2509%2509%2
> 509%253CPropertyName%253EPROVINCIA%253C%252FPropertyName%253E%253CLite
> ral%253E1%253C%252FLiteral%253E%250A%2509%2509%2509%2509%2509%2509%250
> 9%253C%252FPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%2509%2
> 509%253CPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%2509%2509
> %2509%253CPropertyName%253EMUNICIPIO%253C%252FPropertyName%253E%253CLi
> teral%253E1%253C%252FLiteral%253E%250A%2509%2509%2509%2509%2509%2509%2
> 509%253C%252FPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%2509
> %2509%253CPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%2509%25
> 09%2509%253CPropertyName%253EPOLIGONO%253C%252FPropertyName%253E%253CL
> iteral%253E1%253C%252FLiteral%253E%250A%2509%2509%2509%2509%2509%2509%
> 2509%253C%252FPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%250
> 9%2509%253CPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%2509%2
> 509%2509%253CPropertyName%253EPARCELA%253C%252FPropertyName%253E%253CL
> iteral%253E86%253C%252FLiteral%253E%250A%2509%2509%2509%2509%2509%2509
> %2509%253C%252FPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%25
> 09%2509%253CPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%2509%
> 2509%2509%253CPropertyName%253ERECINTO%253C%252FPropertyName%253E%253C
> Literal%253E1%253C%252FLiteral%253E%250A%2509%2509%2509%2509%2509%2509
> %2509%253C%252FPropertyIsEqualTo%253E%250A%2509%2509%2509%2509%2509%25
> 09%253C%252FAnd%253E%250A%2509%2509%2509%2509%2509%253C%252FOr%253E%25
> 0A%2509%2509%2509%2509%253C%252FFilter%253E%2520%250A%2509%2509%2509%2
> 53C%252Fwfs%253AQuery%253E%253C%252Fwfs%253AGetFeature%253E HTTP/1.1" 
> 200 -
>
> Maybe there is something wrong with webproxy.php???
>
> Thanks in advance.
>
> David,
>
> I just skimmed the text of post XML, but if your OpenLayers app is sending a query to MapServer, your layer will need a template.  In the case of WFS, I don't think that you need a real template file.  But, you still might need an entry  in your LAYER that is something like TEMPLATE "dummy.html".
>
> David.
>
> -----Original Message-----
> From: mapserver-users-bounces at lists.osgeo.org 
> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of David 
> Alda Fernandez de Lezea
> Sent: Monday, June 21, 2010 6:59 AM
> To: mapserver-users at lists.osgeo.org
> Subject: [mapserver-users] RV: [OpenLayers-Users] Strange behaviour 
> with OpenLayers.Request.POST and MapServer
>
>
> Hi list,
>
> I posted this question in OpenLayers mailing list but without response, maybe here someone knwos what could be happening. I'm trying to load some data from a remote WFS Server (MapServer). At the beginning I used OpenLayers.Request.POST({url: this.onlineResource, callback: callbackFunction, method: 'POST', data: filter}); to load the features and it worked perfectly, but now, due to some architecture issues, I have to make the request over a proxy script made in php, but I don't get the features. I don't get any OpenLayers error but I get an error from MapServer:
>
> Error:
> mapserv(): Web application error. Traditional BROWSE mode requires a TEMPLATE in the WEB section, but none was provided.
>
> Request:
>
> OpenLayers.Request.POST({url: networkSettings.proxyURL + 
> "?method=POST&url=" + escape(this.onlineResource) + "&data=" + filtro, 
> callback: callbackFunction, method: 'POST', headers: {"Content-Type": 
> "text/xml; charset=utf-8"}});
>
> Web Proxy:
>
> <?
>
>        $strURL = @$_REQUEST["url"];
>        $strMethod = @$_REQUEST["method"];
>        $strData = @$_REQUEST["data"];
>
>        $ch = curl_init();
>        curl_setopt($ch, CURLOPT_URL, $strURL);
>        if ($strMethod == "POST"){
>                curl_setopt($ch, CURLOPT_POST, 1);
>                curl_setopt($ch, CURLOPT_POSTFIELDS, $strData);
>        }
>
>        $data = curl_exec($ch);
>        curl_close($ch);
>
> ?>
>
> In Firebug I can see all the parameters:
>
> data    <?xml version="1.0" ?><wfs:GetFeature service="WFS" version="1.1.0" outputFormat="text/xml; subtype=gml/3.1.1" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.1.0/WFS.xsd"><wfs:Query typeName="RecintosSigpac"><PropertyName>msGeometry</PropertyName>  <Filter><Or><And><PropertyIsEqualTo><PropertyName>PROVINCIA</PropertyName><Literal>1</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>MUNICIPIO</PropertyName><Literal>1</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>POLIGONO</PropertyName><Literal>1</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>PARCELA</PropertyName><Literal>1</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>RECINTO</PropertyName><Literal>1</Literal></PropertyIsEqualTo></And><And><PropertyIsEqualTo><PropertyName>PROVINCIA</PropertyName><Literal>1</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>MUNICIPIO</PropertyName><Literal>1</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>POLIGONO</PropertyName><Literal>1</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>PARCELA</PropertyName><Literal>86</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>RECINTO</PropertyName><Literal>1</Literal></PropertyIsEqualTo></And></Or></Filter>  </wfs:Query></wfs:GetFeature>
> method  POST
> url     http://192.168.1.65/cgi-bin/mapserv.exe?map=../htdocs/MFD/ejemplo_wfs.map&
>
> And in Apache access.log I get :
>
> 192.168.1.65 - - [21/Jun/2010:13:44:56 +0200] "POST 
> /webproxy.php?&url=http%3A%2F%2F192.168.1.65%2Fcgi-bin%2Fmapserv.exe%3
> Fmap%3D..%2Fhtdocs%2FMFD%2Fejemplo_wfs.map%26&method=POST&data=%3C%3Fx
> ml%20version%3D%221.0%22%20%3F%3E%3Cwfs%3AGetFeature%20service%3D%22WF
> S%22%20version%3D%221.1.0%22%20outputFormat%3D%22text%2Fxml%3B%20subty
> pe%3Dgml%2F3.1.1%22%20xmlns%3Awfs%3D%22http%3A%2F%2Fwww.opengis.net%2F
> wfs%22%20xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%20xmln
> s%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20
> xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.opengis.net%2Fwfs%20..%2Fwf
> s%2F1.1.0%2FWFS.xsd%22%3E%3Cwfs%3AQuery%20typeName%3D%22RecintosSigpac
> %22%3E%3CPropertyName%3EmsGeometry%3C%2FPropertyName%3E%0A%09%09%09%09
> %20%3CFilter%3E%0A%09%09%09%09%09%3COr%3E%0A%09%09%09%09%09%09%3CAnd%3
> E%0A%09%09%09%09%09%09%09%3CPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%
> 09%09%3CPropertyName%3EPROVINCIA%3C%2FPropertyName%3E%3CLiteral%3E1%3C
> %2FLiteral%3E%0A%09%09%09%09%09%09%09%3C%2FPropertyIsEqualTo%3E%0A%09%
> 09%09%09%09%09%09%3CPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%09%09%3C
> PropertyName%3EMUNICIPIO%3C%2FPropertyName%3E%3CLiteral%3E1%3C%2FLiter
> al%3E%0A%09%09%09%09%09%09%09%3C%2FPropertyIsEqualTo%3E%0A%09%09%09%09
> %09%09%09%3CPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%09%09%3CProperty
> Name%3EPOLIGONO%3C%2FPropertyName%3E%3CLiteral%3E1%3C%2FLiteral%3E%0A%
> 09%09%09%09%09%09%09%3C%2FPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%09
> %3CPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%09%09%3CPropertyName%3EPA
> RCELA%3C%2FPropertyName%3E%3CLiteral%3E1%3C%2FLiteral%3E%0A%09%09%09%0
> 9%09%09%09%3C%2FPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%09%3CPropert
> yIsEqualTo%3E%0A%09%09%09%09%09%09%09%09%3CPropertyName%3ERECINTO%3C%2
> FPropertyName%3E%3CLiteral%3E1%3C%2FLiteral%3E%0A%09%09%09%09%09%09%09
> %3C%2FPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%3C%2FAnd%3E%0A%09%09%0
> 9%09%09%09%3CAnd%3E%0A%09%09%09%09%09%09%09%3CPropertyIsEqualTo%3E%0A%
> 09%09%09%09%09%09%09%09%3CPropertyName%3EPROVINCIA%3C%2FPropertyName%3
> E%3CLiteral%3E1%3C%2FLiteral%3E%0A%09%09%09%09%09%09%09%3C%2FPropertyI
> sEqualTo%3E%0A%09%09%09%09%09%09%09%3CPropertyIsEqualTo%3E%0A%09%09%09
> %09%09%09%09%09%3CPropertyName%3EMUNICIPIO%3C%2FPropertyName%3E%3CLite
> ral%3E1%3C%2FLiteral%3E%0A%09%09%09%09%09%09%09%3C%2FPropertyIsEqualTo
> %3E%0A%09%09%09%09%09%09%09%3CPropertyIsEqualTo%3E%0A%09%09%09%09%09%0
> 9%09%09%3CPropertyName%3EPOLIGONO%3C%2FPropertyName%3E%3CLiteral%3E1%3
> C%2FLiteral%3E%0A%09%09%09%09%09%09%09%3C%2FPropertyIsEqualTo%3E%0A%09
> %09%09%09%09%09%09%3CPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%09%09%3
> CPropertyName%3EPARCELA%3C%2FPropertyName%3E%3CLiteral%3E86%3C%2FLiter
> al%3E%0A%09%09%09%09%09%09%09%3C%2FPropertyIsEqualTo%3E%0A%09%09%09%09
> %09%09%09%3CPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%09%09%3CProperty
> Name%3ERECINTO%3C%2FPropertyName%3E%3CLiteral%3E1%3C%2FLiteral%3E%0A%0
> 9%09%09%09%09%09%09%3C%2FPropertyIsEqualTo%3E%0A%09%09%09%09%09%09%3C%
> 2FAnd%3E%0A%09%09%09%09%09%3C%2FOr%3E%0A%09%09%09%09%3C%2FFilter%3E%20
> %0A%09%09%09%3C%2Fwfs%3AQuery%3E%3C%2Fwfs%3AGetFeature%3E
>
> HTTP/1.1" 200 2508
>
> This seems to be OK, isn't it?
>
> Am I doing something wrong with the new request??
>
> Thanks in advance.
>
> Un saludo,
>
> ······································································
> ············
>
> David Alda Fernández de Lezea
> Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y 
> Biodiversidad
>
> IKT
> Granja Modelo s/n · 01192 · Arkaute (Araba)
>
> ··················································································
> Tlfnos.: 945-00-32-95                         Fax: 945-00.32.90
> ··················································································
> email: dalda at ikt.es                                web: www.ikt.es
> ······································································
> ············ _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

Regards,
--
Christopher Schmidt
Nokia




More information about the Users mailing list