0

i am tring to search for a specific record in geonetwork with owslib, according to documentation in https://geopython.github.io/OWSLib/. but it fails :

>>> geonetwork = 'http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/csw'
>>> 
>>> from owslib.csw import CatalogueServiceWeb
>>> csw = CatalogueServiceWeb(geonetwork)
>>> 
>>> csw.getrecordbyid(id=['8174d16d-240f-4199-9c2f-af6976e376b3'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 293, in getrecordbyid
    self._invoke()
  File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 647, in _invoke
    self.response = openURL(self.request, None, 'Get', username=self.username, password=self.password, timeout=self.timeout).read()
  File "/usr/lib/python2.7/dist-packages/owslib/util.py", line 186, in openURL
    **rkwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 437, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError:  HTTPConnectionPool(host='localhost', port=8080):  
Max retries exceeded with url: /geonetwork/srv/fre/csw?outputFormat=application%2Fxml&service=CSW&outputSchema=http%3A%2F%2Fwww.opengis.net%2Fcat%2Fcsw%2F2.0.2&request=GetRecordById&version=2.0.2&elementsetname=full&id=8174d16d-240f-4199-9c2f-af6976e376b3  
(Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f8f1975f510>:  
**Failed to establish a new connection: [Errno 111] Connection refused'**,))

any idea ?

1 Answer 1

2

I'm guessing the CSW you are querying has 'http://localhost:8080' set as it's host in the CSW configuration. OWSLib's CSW support does a GetCapabilities request by default to get this information. You can use the skip_caps=True parameter to bypass this:

csw = CatalogueServiceWeb(geonetwork, skip_caps=True)

which means OWSLib will always use the URL you specify when initializing the CSW. This is not always guaranteed to work as some CSW implementations have URLs which differ depending on the operation.

Having said this, the CSW itself should update its configuration accordingly to prevent this issue from manifesting itself for downstream clients/applications.

1
  • it works also with our geonetwork's geOrchestra instance ! :) but i do not know how to modify the configuration of geonetwork in order to avoid that... to be continued. Apr 30, 2016 at 10:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.