<p dir="ltr"><br>
On May 16, 2016 2:02 PM, "Rahkonen Jukka (MML)" <<a href="mailto:jukka.rahkonen@maanmittauslaitos.fi">jukka.rahkonen@maanmittauslaitos.fi</a>> wrote:<br>
><br>
> Correction:<br>
><br>
>  <br>
><br>
> Changing the WMS online resource does work if the mapfile is written correctly. I had to add VALIDATION also into MAP->WEB<br>
><br>
>  <br>
><br>
> WEB<br>
><br>
>     METADATA<br>
><br>
> "wms_onlineresource" "<a href="http://localhost:8060/cgi-bin/mapserv.exe?map=c">http://localhost:8060/cgi-bin/mapserv.exe?map=c</a>:\ms4w\apps\wms-wfs.map&db=%db%"<br>
><br>
>     END #metadata<br>
><br>
>      VALIDATION<br>
><br>
>              "db" "[a-z]+"<br>
><br>
>     END #validation<br>
><br>
> END #WEB<br>
><br>
>  <br>
><br>
> Now I can send<br>
> <a href="http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w/apps/wms-wfs.map&service=wms&version=1.3.0&request=getcapabilities&db=wms-wfs">http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w/apps/wms-wfs.map&service=wms&version=1.3.0&request=getcapabilities&db=wms-wfs</a><br>
><br>
>  <br>
><br>
> and get<br>
> <OnlineResource xlink:href="<a href="http://localhost:8060/cgi-bin/mapserv.exe?map=c">http://localhost:8060/cgi-bin/mapserv.exe?map=c</a>:\ms4w\apps\wms-wfs.map&db=wms-wfs&"/><br>
><br>
>  <br>
><br>
> What is interesting is that the validation rule “[a-z]+” should not accept the name of my db “wms-wfs” but it does. Capital letters are accepted as well “WMS-WFS”. Because I am on Windows I can even get data with WMS-WFS though the name of the db is “wms-wfs.sqlite”.<br>
><br>
That's because [a-z]+ means "there should be at least one alphabetic character in the passed expression". The " correct" regex to use would be ^[a-z]+$</p>
<p dir="ltr">Thomas<br>
>  <br>
><br>
> -Jukka Rahkonen-<br>
><br>
>  <br>
><br>
>  <br>
><br>
> Lähettäjä: Rahkonen Jukka (MML) <br>
> Lähetetty: 16. toukokuuta 2016 14:24<br>
> Vastaanottaja: 'G. Allegri'; <a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
> Aihe: Re: [mapserver-users] runtime CONNECTION string partial substitution<br>
><br>
>  <br>
><br>
> Hi,<br>
><br>
>  <br>
><br>
> I made a test with your VALIDATION and CONNECTION and changing  db on-the-fly works. How did you test?  If you use some WMS client for testing it is good to remember that variable substitution does not have an effect on the GetCapabilities document so that the GetMap URL would be updated automatically. Therefore WMS clients like QGIS or OpenJUMP will drop the &db= parameter from the GetMaps if you do not tell them not to trust the advertised GetMap URL.<br>
><br>
>  <br>
><br>
> According to documentation <a href="http://mapserver.org/cgi/runsub.html">http://mapserver.org/cgi/runsub.html</a>  it should also be possible to use variable substitution also in MAP- WEB: METADATA. I tried<br>
><br>
> to use<br>
><br>
> "wms_onlineresource" “<a href="http://localhost:8060/cgi-bin/mapserv.exe?map=c">http://localhost:8060/cgi-bin/mapserv.exe?map=c</a>:\ms4w\apps\wms-wfs.map&%db%”<br>
><br>
>  <br>
><br>
> but GetCapabilities response contains the variable %db% literally<br>
><br>
> <OnlineResource xlink:href="<a href="http://localhost:8060/cgi-bin/mapserv.exe?map=c">http://localhost:8060/cgi-bin/mapserv.exe?map=c</a>:\ms4w\apps\wms-wfs.map&%db%&"/><br>
><br>
>  <br>
><br>
> It seems that for getting a proper error message when &db= is missing or it is wrong a WMS GetMap request is required. WFS GetFeature triggers the error<br>
><br>
> and is easier to write by hand, for example:<br>
><br>
> <a href="http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w/apps/wms-wfs.map&service=wfs&version=2.0.0&request=getfeature&typename=states&db=foo">http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w/apps/wms-wfs.map&service=wfs&version=2.0.0&request=getfeature&typename=states&db=foo</a><br>
><br>
> sends an error<br>
><br>
> <ows:ExceptionText><br>
><br>
> msOGRFileOpen(): OGR error. Open failed for OGR connection in layer `states'.  File not found or unsupported format.<br>
><br>
> </ows:ExceptionText><br>
><br>
>  <br>
><br>
> Document <a href="http://www.mapserver.org/optimization/debugging.html">http://www.mapserver.org/optimization/debugging.html</a> contains good advice for debugging.<br>
><br>
>  <br>
><br>
> -Jukka Rahkonen-<br>
><br>
>  <br>
><br>
>  <br>
><br>
> G. Allegri wrote:<br>
><br>
>  <br>
><br>
> Hello,<br>
><br>
> I'm trying to define a layer where the Sqlite DB connection should be set dynamically through runtime sustitution.<br>
><br>
>  <br>
><br>
> e.g.<br>
><br>
>  <br>
><br>
> LAYER<br>
><br>
>     NAME mylayer<br>
><br>
>     TYPE POINT<br>
><br>
>     CONNECTIONTYPE OGR<br>
><br>
>     VALIDATION<br>
><br>
>         "db" "[a-z]+"<br>
><br>
>     END<br>
><br>
>     CONNECTION "/var/www/dbs/%db%.sqlite"<br>
><br>
>     DATA "mytable"<br>
><br>
> END<br>
><br>
>  <br>
><br>
> The point layers works fine if  %db% is set statically but if I try to define it through get query values nothing is returned:<br>
><br>
>  <br>
><br>
> <a href="http://localhost/cgi-bin/mapserv?map=mymapfile.map&db=mydb">http://localhost/cgi-bin/mapserv?map=mymapfile.map&db=mydb</a><br>
><br>
>  <br>
><br>
> The documentation says that runtime sustitution should work for CONNECTION param too. What am I doing wrong?<br>
><br>
>  <br>
><br>
> Thanks,<br>
><br>
> Giovanni<br>
><br>
>  <br>
><br>
> --<br>
><br>
> Giovanni Allegri<br>
> <a href="http://about.me/giovanniallegri">http://about.me/giovanniallegri</a><br>
><br>
> Gis3W - <a href="http://gis3w.it">http://gis3w.it</a><br>
><br>
> Ikare - <a href="http://ikare.it">http://ikare.it</a><br>
><br>
> Twitter: <a href="https://twitter.com/_giohappy_">https://twitter.com/_giohappy_</a><br>
><br>
> blog: <a href="http://blog.spaziogis.it">http://blog.spaziogis.it</a><br>
> GEO+ geomatica in Italia <a href="http://bit.ly/GEOplus">http://bit.ly/GEOplus</a><br>
><br>
><br>
> _______________________________________________<br>
> mapserver-users mailing list<br>
> <a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
</p>