Discussion:
[mapserver-users] MapServer 7.0 WFS post request using ogc filter
TMa Teng
2016-08-17 14:57:44 UTC
Permalink
Hi guys,

I am currently facing problems using WFS in MapServer 7.0. The WFS works in MapServer 6.0.4 before I upgrade MapServer 7.0 and Mapfile, database connection everything has not been changed. Is there any change to WFS call from MapServer version 6.0 to version 7.x? Please advise me if there is anything I am missing.


My request body:
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" maxFeatures="200" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="parcelpoints" xmlns:feature="http://mapserver.gis.umn.edu/mapserver">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>shape</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
<gml:lowerCorner>-81 41</gml:lowerCorner>
<gml:upperCorner>-80.9 41.01</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

Thanks in advance,

Martin
Even Rouault
2016-08-17 15:37:26 UTC
Permalink
Post by TMa Teng
Hi guys,
I am currently facing problems using WFS in MapServer 7.0. The WFS works in
MapServer 6.0.4 before I upgrade MapServer 7.0 and Mapfile, database
connection everything has not been changed. Is there any change to WFS
call from MapServer version 6.0 to version 7.x? Please advise me if there
is anything I am missing.
You didn't explain what didn't work exactly. Like do you get a response with
zero features in it ?

This might be an issue with the coordinate order of in lowerCorner and
upperCorner query. I assume that the SRS of the layer is EPSG:4326 ? If so,
you should likely put the values in latitude longitude order (they look like
being longitude latitude in your below sample). And it would also be better to
explictly specify the SRS by adding a srsName="urn:ogc:def:crs:EPSG::4326"
attribute to the <gml:Envelope> element.
Post by TMa Teng
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.1.0" maxFeatures="200"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <wfs:Query
typeName="parcelpoints"
xmlns:feature="http://mapserver.gis.umn.edu/mapserver"> <ogc:Filter
xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>shape</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
<gml:lowerCorner>-81 41</gml:lowerCorner>
<gml:upperCorner>-80.9 41.01</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
Thanks in advance,
Martin
--
Spatialys - Geospatial professional services
http://www.spatialys.com
Even Rouault
2016-08-17 16:01:14 UTC
Permalink
Thank you Even. The error message is " The gateway did not receive a timely
response from the upstream server or application".
Do other GetFeature queries work ? GetCapabilities ?
I didn’t specify the srsname in the query since output is defined in
EPSG:4326 same as the mapfile. I have an identical server that has not
been upgrade to mapserver 7.0 yet. And it returns the fesature collection
successfully using exact the same mapfile and same request body.
Martin
-----Original Message-----
Sent: Wednesday, August 17, 2016 11:37 AM
Subject: Re: [mapserver-users] MapServer 7.0 WFS post request using ogc
filter
Post by TMa Teng
Hi guys,
I am currently facing problems using WFS in MapServer 7.0. The WFS
works in MapServer 6.0.4 before I upgrade MapServer 7.0 and Mapfile,
database connection everything has not been changed. Is there any
change to WFS call from MapServer version 6.0 to version 7.x? Please
advise me if there is anything I am missing.
You didn't explain what didn't work exactly. Like do you get a response
with zero features in it ?
This might be an issue with the coordinate order of in lowerCorner and
upperCorner query. I assume that the SRS of the layer is EPSG:4326 ? If
so, you should likely put the values in latitude longitude order (they
look like being longitude latitude in your below sample). And it would
also be better to explictly specify the SRS by adding a
srsName="urn:ogc:def:crs:EPSG::4326" attribute to the <gml:Envelope>
element.
Post by TMa Teng
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.1.0" maxFeatures="200"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <wfs:Query
typeName="parcelpoints"
xmlns:feature="http://mapserver.gis.umn.edu/mapserver"> <ogc:Filter
xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>shape</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
<gml:lowerCorner>-81 41</gml:lowerCorner>
<gml:upperCorner>-80.9 41.01</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
Thanks in advance,
Martin
--
Spatialys - Geospatial professional services http://www.spatialys.com
--
Spatialys - Geospatial professional services
http://www.spatialys.com
TMa Teng
2016-08-17 17:31:40 UTC
Permalink
Yes, I am able to use GET method to get the features when use the WFS.

Get request example:
http://gisappsdev:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/SanbornImage_wfs.map&REQUEST=GetFeature&SERVICE=WFS&VERSION=1.0.0&TYPENAME=SanbornGeoref&MAXFEATURES=20&bbox=-72.93411254882812,41.30730211327143,-72.93099045753479,41.30866411858396

It returns features as expected.

The problem is when I try to get features using POST method on the same WFS (see raw in fiddler below):

POST http://gisappsdev:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/SanbornImage_wfs.map HTTP/1.1
Content-Type: multipart/form-data;
User-Agent: Fiddler
Content-Length: 814
Host: gisappsdev:8080

<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" maxFeatures="100" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="SanbornGeoref" xmlns:feature="http://gisappsdev:8080/cgi-bin/mapserv.exe" srsName="EPSG:4326">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>shape</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
<gml:lowerCorner>-81 41</gml:lowerCorner>
<gml:upperCorner>-80.9 41.01</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

It took very long to return a 504 error gameway timeout.

Thanks,


-----Original Message-----
From: Even Rouault [mailto:***@spatialys.com]
Sent: Wednesday, August 17, 2016 12:01 PM
To: TMa Teng <***@edrnet.com>
Cc: mapserver-***@lists.osgeo.org
Subject: Re: [mapserver-users] MapServer 7.0 WFS post request using ogc filter
Thank you Even. The error message is " The gateway did not receive a
timely response from the upstream server or application".
Do other GetFeature queries work ? GetCapabilities ?
I didn’t specify the srsname in the query since output is defined in
EPSG:4326 same as the mapfile. I have an identical server that has not
been upgrade to mapserver 7.0 yet. And it returns the fesature
collection successfully using exact the same mapfile and same request body.
Martin
-----Original Message-----
Sent: Wednesday, August 17, 2016 11:37 AM
Subject: Re: [mapserver-users] MapServer 7.0 WFS post request using
ogc filter
Post by TMa Teng
Hi guys,
I am currently facing problems using WFS in MapServer 7.0. The WFS
works in MapServer 6.0.4 before I upgrade MapServer 7.0 and Mapfile,
database connection everything has not been changed. Is there any
change to WFS call from MapServer version 6.0 to version 7.x? Please
advise me if there is anything I am missing.
You didn't explain what didn't work exactly. Like do you get a
response with zero features in it ?
This might be an issue with the coordinate order of in lowerCorner
and upperCorner query. I assume that the SRS of the layer is EPSG:4326
? If so, you should likely put the values in latitude longitude order
(they look like being longitude latitude in your below sample). And it
would also be better to explictly specify the SRS by adding a
srsName="urn:ogc:def:crs:EPSG::4326" attribute to the <gml:Envelope>
element.
Post by TMa Teng
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.1.0" maxFeatures="200"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <wfs:Query
typeName="parcelpoints"
xmlns:feature="http://mapserver.gis.umn.edu/mapserver"> <ogc:Filter
xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>shape</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
<gml:lowerCorner>-81 41</gml:lowerCorner>
<gml:upperCorner>-80.9 41.01</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
Thanks in advance,
Martin
--
Spatialys - Geospatial professional services http://www.spatialys.com
--
Spatialys - Geospatial professional services http://www.spatialys.com
Jeff McKenna
2016-08-17 20:45:01 UTC
Permalink
Could you try to duplicate your filter request, manually? Here is an
example from the MapServer WFS Filter Encoding howto:

http://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter><BBOX><PropertyName>Name>NAME</PropertyName><Box
srsName='EPSG:4326'><coordinates>135.2239,34.4879
135.8578,34.8471</coordinates></Box></BBOX></Filter>

Does a manually-created filter request work for you? (it just takes a
little time to write the full request through the url, but it is very
useful for testing)

More working filters can be found in the howto:
http://mapserver.org/ogc/filter_encoding.html

-jeff
--
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/
Post by TMa Teng
Yes, I am able to use GET method to get the features when use the WFS.
http://gisappsdev:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/SanbornImage_wfs.map&REQUEST=GetFeature&SERVICE=WFS&VERSION=1.0.0&TYPENAME=SanbornGeoref&MAXFEATURES=20&bbox=-72.93411254882812,41.30730211327143,-72.93099045753479,41.30866411858396
It returns features as expected.
TMa Teng
2016-08-18 13:50:32 UTC
Permalink
Hi Jeff,

The filter encoding does not work on the new instance which runs Mapserver 7.0 but the same request runs correctly when I use Mapserver 6.0.4 with duplicated mapfile and filter.

My test filter request is as below:

http://gisappsproawvc2:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/SanbornImage_wfs.map&&REQUEST=GetFeature&SERVICE=WFS&VERSION=1.0.0&TYPENAME=SanbornGeoref&MAXFEATURES=200& &Filter=<Filter><BBOX><PropertyName>shape</PropertyName><Box srsName='EPSG:4326'><coordinates>-73.2239,33.4879 -71.8578,34.8471</coordinates></Box></BBOX></Filter>

I am not sure why it is not working when I switch to newer version. That being said, there could be some part I missed when I install/configure Mapserver. I am using MS4W 3.1.4, data source is in SQL Server spatial.
Please advise how could I troubleshoot this.

Thanks,

-----Original Message-----
From: mapserver-users [mailto:mapserver-users-***@lists.osgeo.org] On Behalf Of Jeff McKenna
Sent: Wednesday, August 17, 2016 4:45 PM
To: mapserver-***@lists.osgeo.org
Subject: Re: [mapserver-users] MapServer 7.0 WFS post request using ogc filter

Could you try to duplicate your filter request, manually? Here is an example from the MapServer WFS Filter Encoding howto:

http://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter><BBOX><PropertyName>Name>NAME</PropertyName><Box
srsName='EPSG:4326'><coordinates>135.2239,34.4879
135.8578,34.8471</coordinates></Box></BBOX></Filter>

Does a manually-created filter request work for you? (it just takes a little time to write the full request through the url, but it is very useful for testing)

More working filters can be found in the howto:
http://mapserver.org/ogc/filter_encoding.html

-jeff
--
Jeff McKenna
MapServer Consulting and Training Services http://www.gatewaygeomatics.com/
Post by TMa Teng
Yes, I am able to use GET method to get the features when use the WFS.
http://gisappsdev:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/SanbornImage_wfs.map&REQUEST=GetFeature&SERVICE=WFS&VERSION=1.0.0&TYPENAME=SanbornGeoref&MAXFEATURES=20&bbox=-72.93411254882812,41.30730211327143,-72.93099045753479,41.30866411858396
It returns features as expected.
_______________________________________________
mapserver-users mailing list
mapserver-***@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Lime, Steve D (MNIT)
2016-08-19 18:55:20 UTC
Permalink
What does "not work" mean? Is there an error message or are you seeing an incorrect result set? What does the layer definition look like?

Steve

-----Original Message-----
From: mapserver-users [mailto:mapserver-users-***@lists.osgeo.org] On Behalf Of TMa Teng
Sent: Thursday, August 18, 2016 8:51 AM
To: mapserver-***@lists.osgeo.org
Subject: Re: [mapserver-users] MapServer 7.0 WFS post request using ogc filter

Hi Jeff,

The filter encoding does not work on the new instance which runs Mapserver 7.0 but the same request runs correctly when I use Mapserver 6.0.4 with duplicated mapfile and filter.

My test filter request is as below:

http://gisappsproawvc2:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/SanbornImage_wfs.map&&REQUEST=GetFeature&SERVICE=WFS&VERSION=1.0.0&TYPENAME=SanbornGeoref&MAXFEATURES=200& &Filter=<Filter><BBOX><PropertyName>shape</PropertyName><Box srsName='EPSG:4326'><coordinates>-73.2239,33.4879 -71.8578,34.8471</coordinates></Box></BBOX></Filter>

I am not sure why it is not working when I switch to newer version. That being said, there could be some part I missed when I install/configure Mapserver. I am using MS4W 3.1.4, data source is in SQL Server spatial.
Please advise how could I troubleshoot this.

Thanks,

-----Original Message-----
From: mapserver-users [mailto:mapserver-users-***@lists.osgeo.org] On Behalf Of Jeff McKenna
Sent: Wednesday, August 17, 2016 4:45 PM
To: mapserver-***@lists.osgeo.org
Subject: Re: [mapserver-users] MapServer 7.0 WFS post request using ogc filter

Could you try to duplicate your filter request, manually? Here is an example from the MapServer WFS Filter Encoding howto:

http://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter><BBOX><PropertyName>Name>NAME</PropertyName><Box
srsName='EPSG:4326'><coordinates>135.2239,34.4879
135.8578,34.8471</coordinates></Box></BBOX></Filter>

Does a manually-created filter request work for you? (it just takes a little time to write the full request through the url, but it is very useful for testing)

More working filters can be found in the howto:
http://mapserver.org/ogc/filter_encoding.html

-jeff
--
Jeff McKenna
MapServer Consulting and Training Services http://www.gatewaygeomatics.com/
Post by TMa Teng
Yes, I am able to use GET method to get the features when use the WFS.
http://gisappsdev:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/SanbornImage_wfs.map&REQUEST=GetFeature&SERVICE=WFS&VERSION=1.0.0&TYPENAME=SanbornGeoref&MAXFEATURES=20&bbox=-72.93411254882812,41.30730211327143,-72.93099045753479,41.30866411858396
It returns features as expected.
_______________________________________________
mapserver-users mailing list
mapserver-***@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-***@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Even Rouault
2016-08-18 09:31:58 UTC
Permalink
Post by TMa Teng
Yes, I am able to use GET method to get the features when use the WFS.
http://gisappsdev:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/Sanb
ornImage_wfs.map&REQUEST=GetFeature&SERVICE=WFS&VERSION=1.0.0&TYPENAME=Sanb
ornGeoref&MAXFEATURES=20&bbox=-72.93411254882812,41.30730211327143,-72.9309
9045753479,41.30866411858396
It returns features as expected.
The problem is when I try to get features using POST method on the same WFS
POST
http://gisappsdev:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/SanbornImage/San
bornImage_wfs.map HTTP/1.1 Content-Type: multipart/form-data;
User-Agent: Fiddler
Content-Length: 814
Host: gisappsdev:8080
I've tried the following with a mapfile from MapServer test suite :

cat request.xml | CONTENT_TYPE=text/xml MS_MAPFILE=wfs_200.map REQUEST_METHOD=POST mapserv

where request.xml is as close as possible to yours :

<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0"
maxFeatures="100" xsi:schemaLocation="http://www.opengis.net/wfshttp://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="province" xmlns:feature="http://gisappsdev:8080/cgi-bin/mapserv.exe" srsName="EPSG:4326">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>shape</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
<gml:lowerCorner>-81 41</gml:lowerCorner>
<gml:upperCorner>-80.9 41.01</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

And it returns:

Content-Type: text/xml; subtype=gml/3.1.1; charset=UTF-8

<?xml version='1.0' encoding="UTF-8" ?>
<wfs:FeatureCollection
xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
xmlns:gml="http://www.opengis.net/gml"
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://mapserver.gis.umn.edu/mapserver
http://localhost/path/to/wfs_simple?myparam=something&amp;SERVICE=WFS&amp;VERSION=1.1.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=province&amp;OUTPUTFORMAT=text/xml;
%20subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<gml:boundedBy>
<gml:Null>missing</gml:Null>
</gml:boundedBy>
</wfs:FeatureCollection>

So it behaves as expected.

Looking at the above header, this might perhaps come from "Content-Type: multipart/form-data;" The terminating semi-column is a bit suspicous. Also
this is incorrect in that instance and should be "text/xml".
Another possibilitiy, more likely, is that the Content-Length is wrong. If I paste your below XML with DOS end-of-line (CR-LF), I get 813 bytes (or 815 if I add an extra return line), not 814.
So MapServer could try to read one extra byte that never comes, hence the timeout.
Post by TMa Teng
<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.1.0" maxFeatures="100"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <wfs:Query
typeName="SanbornGeoref"
xmlns:feature="http://gisappsdev:8080/cgi-bin/mapserv.exe"
srsName="EPSG:4326"> <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>shape</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
<gml:lowerCorner>-81 41</gml:lowerCorner>
<gml:upperCorner>-80.9 41.01</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
--
Spatialys - Geospatial professional services
http://www.spatialys.com
Loading...