In Python 2.7, I try to do a WFS request from behind an authenticated proxy server (proxy requiring username/password). I managed to communicate to a webserver via the authenticated proxy using a ProxyHandler. I also managed to communicate with a WFS server in a network without the proxy. Now I'd like to combine the two. This is my code for testing:
from owslib.wfs import WebFeatureServiceimport urllib2proxy_url = 'username
assword@server
ort' # replace with real settings!proxy = urllib2.ProxyHandler({'https': proxy_url})opener = urllib2.build_opener(proxy, urllib2.HTTPHandler)urllib2.install_opener(opener)wfs_url = 'https://viewer.image-v.be/MM_Opnameposities?service=WFS&request=GetCapabilities'response = urllib2.urlopen(wfs_url, timeout=1)print response.read()# is okwfs_url = 'https://viewer.image-v.be/MM_Opnameposities'wfs = WebFeatureService(wfs_url)# error: Failed to establish a new connection: [Errno 10060]gml = wfs.getfeature( typename='orbit:MM_AGIV_MR__1', bbox=(207943,166669,208043,166769), srsname='urn:x-ogc:def:crs:EPSG:31370' )print gml.read()# is not okAlso note that the WFS server uses HTTPS: this could make things more complicated.
Why do I get an error trying to instantiate a WebFeatureService object?Does the WebFeatureService object actually use the installed opener? If not, how can I make sure the WebFeatureService (or any Web-x-Service communication in library owslib) is taking the proxy settings into account? I've looked into the code of WebFeatureService and urllib2.urlopen is used there as well.
Thanks.
أكثر...
from owslib.wfs import WebFeatureServiceimport urllib2proxy_url = 'username
Why do I get an error trying to instantiate a WebFeatureService object?Does the WebFeatureService object actually use the installed opener? If not, how can I make sure the WebFeatureService (or any Web-x-Service communication in library owslib) is taking the proxy settings into account? I've looked into the code of WebFeatureService and urllib2.urlopen is used there as well.
Thanks.
أكثر...