Reputation: 65
Python: 2.7.6
zeep: 1.1.0
I'm trying to reach the WSDL endpoint of a web service URL. I'm currently using the zeep SOAP client and have also tried suds (and gotten similar results). When I access the URL from the web or send a curl request to it, I get a response and can see the services. But when I try to access it from zeep (using the python -mzeep [url] command) or suds (by just print(client)) I get a connection error.
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
I have pasted the full error below. Unfortunately I am unable to share the URL here so I'm changing it for my post.
In my code I have the following
from zeep import Client
endpoint_url = 'http://12.345.678.90:8080/PathGoesHere?wsdl'
client = Client(endpoint_url)
I have also tried the following
sudo python -mzeep http://12.345.678.90:8080/PathGoesHere?wsdl
ERROR:
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/zeep/__main__.py", line 86, in <module>
main(args)
File "/usr/local/lib/python2.7/dist-packages/zeep/__main__.py", line 75, in main
client = Client(args.wsdl_file, transport=transport)
File "/usr/local/lib/python2.7/dist-packages/zeep/client.py", line 120, in __init__
self.wsdl = Document(wsdl, self.transport)
File "/usr/local/lib/python2.7/dist-packages/zeep/wsdl/wsdl.py", line 65, in __init__
root_definitions = Definition(self, document, self.location)
File "/usr/local/lib/python2.7/dist-packages/zeep/wsdl/wsdl.py", line 156, in __init__
self.parse_types(doc)
File "/usr/local/lib/python2.7/dist-packages/zeep/wsdl/wsdl.py", line 272, in parse_types
self.types.add_documents(schema_nodes, self.location)
File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/schema.py", line 96, in add_documents
document = self.create_new_document(node, location)
File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/schema.py", line 183, in create_new_document
schema.load(self, node)
File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/schema.py", line 349, in load
visitor.visit_schema(node)
File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/visitor.py", line 108, in visit_schema
self.process(node, parent=parent)
File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/visitor.py", line 49, in process
result = visit_func(self, node, parent)
File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/visitor.py", line 155, in visit_import
schema_node = load_external(location, self.schema._transport)
File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/utils.py", line 59, in load_external
response = transport.load(url)
File "/usr/local/lib/python2.7/dist-packages/zeep/transports.py", line 111, in load
content = self._load_remote_data(url)
File "/usr/local/lib/python2.7/dist-packages/zeep/transports.py", line 126, in _load_remote_data
response = self.session.get(url, timeout=self.load_timeout)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 487, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='host.goes.here', port=8080): Max retries exceeded with url: /PathGoesHere?xsd=xsd0 (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fbf2c442390>: Failed to establish a new connection: [Errno -2] Name or service not known',))
I'm not sure why it works through browser/curl but not python SOAP clients. Is there something I should be changing in my endpoint URL like setting the port later? I tried that with suds and it gave me a 404 error because of an invalid URL. How should I approach this problem/what else can I try?
Thanks in Advance!
Upvotes: 1
Views: 4809
Reputation: 65
In my situation it seems that changing my url endpoint from
http://12.345.678.90:8080/PathGoesHere?wsdl
to
http://12.345.678.90:8080/PathGoesHere?singleWsdl
did the trick
Upvotes: -1
Reputation: 514
First come to my mind is, are you behind a firewall? This is not a wired error, just because of the URL is not accessible.
For most company environment, you can visit a URL by browser but you cannot access it from command line (or a python library). The reason is, the company policy has been applied to your computer, and the browser uses a proxy script (a pac) file to determine which proxy to use.
If you could share how did you test the URL, which will be very helpful.
Can you please simply use the command ping
to test if that URL is accessible.
Upvotes: 1