Python:2.7.6
zeep:1.1.0
我正在尝试访问Web服务URL的WSDL端点。我目前正在使用zeep SOAP客户端,并且还尝试了suds(并得到了类似的结果)。当我从Web访问URL或向其发送curl请求时,我得到响应并且可以看到服务。但是当我尝试从zeep(使用python -mzeep [url]命令)或suds(仅通过print(客户端))访问它时,我收到连接错误。
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
我已粘贴下面的完整错误。不幸的是我无法在这里分享网址,所以我正在为我的帖子更改它。
在我的代码中,我有以下
from zeep import Client
endpoint_url = 'http://12.345.678.90:8080/PathGoesHere?wsdl'
client = Client(endpoint_url)
我也尝试了以下
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',))
我不确定为什么它可以通过浏览器/ curl工作,但不是python SOAP客户端。我的端点URL中是否应该更改某些内容,例如稍后设置端口?我尝试使用suds,因为URL无效而给了我404错误。我应该如何处理这个问题/我还能尝试什么?
提前致谢!
答案 0 :(得分:0)
首先我想到的是,你是否在防火墙后面?这不是有线错误,只是因为无法访问URL。
对于大多数公司环境,您可以通过浏览器访问URL,但不能从命令行(或python库)访问它。原因是,公司策略已应用于您的计算机,浏览器使用代理脚本(pac)文件来确定要使用的代理。
如果您可以分享如何测试网址,这将非常有用。
您能否只使用命令ping
来测试该URL是否可访问。
答案 1 :(得分:0)
在我的情况下,似乎从
更改我的url端点http://12.345.678.90:8080/PathGoesHere?wsdl
到
http://12.345.678.90:8080/PathGoesHere?singleWsdl
做了这个伎俩