[OWSLib-users] Post XML in owslib.csw.getrecords2

Joana Simoes joana.simoes at starlab.es
Tue Feb 5 04:22:09 PST 2019


Good Morning.

I am trying to use the option getrecords2 with the xml argument (which
should override everything), in order to send a POST request with a body.

This is is the POST request (which works on postman):

<?xml version="1.0" ?>
<csw:GetRecords maxRecords="100" outputFormat="application/xml"
outputSchema="http://www.opengis.net/cat/csw/2.0.2" resultType="results"
service="CSW" version="2.0.2" xmlns:csw="
http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" 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:PropertyIsLike escapeChar="\" singleChar="_"
wildCard="%">
                    <ogc:PropertyName>csw:AnyText</ogc:PropertyName>
                    <ogc:Literal>Walter/SeaDataNet</ogc:Literal>
                </ogc:PropertyIsLike>
            </ogc:Filter>
        </csw:Constraint>
    </csw:Query>
</csw:GetRecords>

And this is the python code to implement this, which does not return any
records.

src.getrecords2(xml='<?xml version="1.0" ?> <csw:GetRecords
maxRecords="100" outputFormat="application/xml" outputSchema="
http://www.opengis.net/cat/csw/2.0.2" resultType="results" service="CSW"
version="2.0.2" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="
http://www.opengis.net/ogc" xmlns:ows="http://www.opengis.net/ows"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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:PropertyIsLike
escapeChar="\" singleChar="_" wildCard="%">
<ogc:PropertyName>csw:AnyText</ogc:PropertyName>
<ogc:Literal>Walter/SeaDataNet</ogc:Literal> </ogc:PropertyIsLike>
</ogc:Filter> </csw:Constraint> </csw:Query> </csw:GetRecords>')

print('results:', src.results)

I wonder what I am doing wrong here. Do I need to replace the single quotes
by double quotes and escape all the characters?

I welcome any tips or suggestions which could point me in the right
direction, as I am running out of ideas here.

                             Thanks in advance!!!
                                         Joana


-- 
Joana Simoes
Technical Lead
Starlab - Living Science

Starlab
Barcelona Offices:
Avinguda Tibidabo 47 bis
08035 Barcelona - Spain
tel: +34 93 254 03 66

e-mail: joana.simoes at starlab.es

Skype: live:joana.simoes_15

website: http://starlab.es
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/owslib-users/attachments/20190205/58078ff6/attachment.html>


More information about the OWSLib-users mailing list