geopython / OWSLib

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
https://owslib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
381 stars 273 forks source link

Can OWSLib output equivalent POST command (e.g. for "curl")? #568

Open rsignell-usgs opened 5 years ago

rsignell-usgs commented 5 years ago

I'm trying to debug what went wrong with my CSW/TerriaMap demo, which issues this curl command:

curl 'https://gamone.whoi.edu/terriamap/proxy/_1d/https://data.ioos.us/csw' -H 'Origin: https://gamone.whoi.edu' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36' -H 'Content-Type: application/xml' -H 'Accept: */*' -H 'Referer: https://gamone.whoi.edu/terriamap/' -H 'Connection: keep-alive' --data-binary '<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" outputSchema="http://www.opengis.net/cat/csw/2.0.2" outputFormat="application/xml" version="2.0.2" service="CSW" resultType="results" startPosition="1" maxRecords="1000" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd"> <csw:Query typeNames="csw:Record"> <csw:ElementSetName>full</csw:ElementSetName> <csw:Constraint version="1.1.0"> <ogc:Filter> <ogc:And>  <ogc:PropertyIsLike wildCard="*" singleChar="?" escapeChar="\"> <ogc:PropertyName>apiso:AnyText</ogc:PropertyName> <ogc:Literal>*ROMS*</ogc:Literal> </ogc:PropertyIsLike> <ogc:PropertyIsLike wildCard="*" singleChar="?" escapeChar="\"> <ogc:PropertyName>apiso:ServiceType</ogc:PropertyName> <ogc:Literal>*WMS*</ogc:Literal> </ogc:PropertyIsLike> </ogc:And> </ogc:Filter> </csw:Constraint> </csw:Query> </csw:GetRecords>' --compressed

This used to work, but is currently returning 0 records, so I'm trying to figure out what the problem is.

When I try the equivalent query with OWSLib, I get the expected 33 records. See notebook here: https://gist.github.com/rsignell-usgs/763a6916df4c5dee6842ca7a4759dc1b

So my question is: is it possible to get OWSLib to spit out the equivalent POST command that could be used in a curl request?

tomkralidis commented 5 years ago

@rsignell-usgs you can inspect the request property of your CSW object to see the actual request put forth. Does that work for you?