ruben-mv / SOSClient

SOS plugin for QGIS
2 stars 2 forks source link

POST URL for Operations Metadata not correctly parsed #4

Closed justb4 closed 9 years ago

justb4 commented 9 years ago

When testing with my 52N SOS at http://sensors.geonovum.nl/sos/service, I found that the plugin was sending requests to the SOAP endpoint, i.e. http://sensors.geonovum.nl/sos/service/soap. The reason I found is that the Operations Metadata from the Capabilities is not correctly parsed. Seems like the last href-value from the list is taken: http://sensors.geonovum.nl/sos/service/soap

    <ows:Operation name="GetObservation">
            <ows:DCP>
                <ows:HTTP>
                    <ows:Get xlink:href="http://sensors.geonovum.nl/sos/service/kvp?">
                        <ows:Constraint name="Content-Type">
                            <ows:AllowedValues>
                                <ows:Value>application/x-kvp</ows:Value>
                            </ows:AllowedValues>
                        </ows:Constraint>
                    </ows:Get>
                    <ows:Post xlink:href="http://sensors.geonovum.nl/sos/service/pox">
                        <ows:Constraint name="Content-Type">
                            <ows:AllowedValues>
                                <ows:Value>application/xml</ows:Value>
                                <ows:Value>text/xml</ows:Value>
                            </ows:AllowedValues>
                        </ows:Constraint>
                    </ows:Post>
                    <ows:Post xlink:href="http://sensors.geonovum.nl/sos/service/soap">
                        <ows:Constraint name="Content-Type">
                            <ows:AllowedValues>
                                <ows:Value>application/soap+xml</ows:Value>
                            </ows:AllowedValues>
                        </ows:Constraint>
                    </ows:Post>
                </ows:HTTP>
            </ows:DCP>

In sos.py the following is executed:

@property
def getObservationsUrl (self):
    try:
        url = QUrl(self.operationsMetadata['GetObservation'].methods['Post'])
        #Para servidores mal configurados
        if url.host() == 'localhost':
            url.setHost (self.url.host())
            url.setPort (self.url.port())
            return url
        return url
    except:
        return QUrl()

When I hardcode the url to url = QUrl('http://sensors.geonovum.nl/sos/service/pox') (Post XML) it works. Or even with http://sensors.geonovum.nl/sos/service (Given that Content-Type is set correctly to application/xml, see next issue #5).

Probably in the sosparser.py around line 48, this happens:

        elif value == "OperationsMetadata":
            opParser = XMLParserFactory.getInstance ("SOSOperationMetadata")
            for opNode, opName in self.search (node, "Operation@name"):
                self.capabilities.operationsMetadata[str(opName)] = opParser().parse(opNode)

Probably it needs to find the entry/URL with Content-Type application/xml or text/xml in the operationsMetadata.

ruben-mv commented 9 years ago

Will be fixed on next release.