Calling SOAP web service by Python WSDL library error - python

I have the following python program on Python 2.7 that uses python WDSL library.
>>> from SOAPpy import WSDL
>>> wsdlFile = 'my_wsdl_file_path'
>>> server = WSDL.Proxy(wsdlFile)
And I get below error;
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/SOAPpy/WSDL.py", line 62, in __init__
self.wsdl = reader.loadFromStream(stream, wsdlsource)
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/WSDLTools.py", line 34, in loadFromStream
wsdl.load(document)
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/WSDLTools.py", line 260, in load
schema = reader.loadFromNode(WSDLToolsAdapter(self), item)
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/XMLSchema.py", line 80, in loadFromNode
schema.load(reader)
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/XMLSchema.py", line 1088, in load
self.addImportSchema(tp.getSchema())
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/XMLSchema.py", line 1205, in getSchema
self._schema = reader.loadFromURL(url)
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/XMLSchema.py", line 114, in loadFromURL
schema.load(reader)
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/XMLSchema.py", line 1120, in load
tp.fromDom(node)
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/XMLSchema.py", line 1764, in fromDom
self.setAttributes(node)
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/XMLSchema.py", line 627, in setAttributes
self.__checkAttributes()
File "/usr/lib/pymodules/python2.7/SOAPpy/wstools/XMLSchema.py", line 681, in __checkAttributes
%(self.getItemTrace(), a, self.attributes[a])
SOAPpy.wstools.XMLSchema.SchemaError: <schema targetNamespace="http://tempuri.org/DataSetGW4.xsd"><element name="DataSetGW4">, unknown attribute(urn:schemas-microsoft-com:xml-msdata,{u'IsDataSet': u'true', u'UseCurrentLocale': u'true'})
what could be the reason?

My experience with SOAPpy is that it is not as complete nor tolerant as Suds. Maybe you should try parsing your WSDL file with suds instead.
import suds.client as client
session = client.Client('file:///absolute/path/to/yourwsdl')

Related

Forbidden for url error from http://schemas.xmlsoap.org/soap/encoding/

I am getting this "Forbidden for url" error when using zeep. Does someone knows what the root cause is?
I have tried to use some options from the Client object of zeep but to no avail.
Or is it something wrong in my WSDL file?
The strange part is that this code used to work fine a few months ago, and suddenly started getting this error.
This is the trace back from the error:
Traceback (most recent call last):
File "/usr/src/app/attpcdaq/daq/tasks.py", line 33, in eccserver_refresh_state_task
ecc_server.refresh_state()
File "/usr/src/app/attpcdaq/daq/models.py", line 428, in refresh_state
client = self._get_soap_client()
File "/usr/src/app/attpcdaq/daq/models.py", line 308, in _get_soap_client
return EccClient(self.ecc_url)
File "/usr/src/app/attpcdaq/daq/models.py", line 65, in __init__
client = SoapClient(wsdl_url) # Loads the service definition from ecc.wsdl
File "/usr/local/lib/python3.7/site-packages/zeep/client.py", line 73, in __init__
self.wsdl = Document(wsdl, self.transport, settings=self.settings)
File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 92, in __init__
self.load(location)
File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 97, in load
root_definitions = Definition(self, document, self.location)
File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 193, in __init__
self._load(doc)
File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 198, in _load
self.parse_types(doc)
File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 330, in parse_types
self.types.add_documents(schema_nodes, self.location)
File "/usr/local/lib/python3.7/site-packages/zeep/xsd/schema.py", line 111, in add_documents
document = self.create_new_document(node, location)
File "/usr/local/lib/python3.7/site-packages/zeep/xsd/schema.py", line 195, in create_new_document
schema.load(self, node)
File "/usr/local/lib/python3.7/site-packages/zeep/xsd/schema.py", line 421, in load
visitor.visit_schema(node)
File "/usr/local/lib/python3.7/site-packages/zeep/xsd/visitor.py", line 165, in visit_schema
self.process(child, parent=node)
File "/usr/local/lib/python3.7/site-packages/zeep/xsd/visitor.py", line 93, in process
result = visit_func(self, node, parent)
File "/usr/local/lib/python3.7/site-packages/zeep/xsd/visitor.py", line 238, in visit_import
schema_node = self._retrieve_data(location, base_url=self.document._location)
File "/usr/local/lib/python3.7/site-packages/zeep/xsd/visitor.py", line 1199, in _retrieve_data
url, self.schema._transport, base_url, settings=self.schema.settings
File "/usr/local/lib/python3.7/site-packages/zeep/loader.py", line 87, in load_external
content = transport.load(url)
File "/usr/local/lib/python3.7/site-packages/zeep/transports.py", line 122, in load
content = self._load_remote_data(url)
File "/usr/local/lib/python3.7/site-packages/zeep/transports.py", line 135, in _load_remote_data
response.raise_for_status()
File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 960, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://schemas.xmlsoap.org/soap/encoding/
You need to cache the WSDL by enabling transport caching:
from zeep.cache import InMemoryCache
Client(soap_url, transport=Transport(
cache=InMemoryCache(),
))
The official documentation recommends using the SqliteCache instead of the InMemoryCache:
from zeep import Client
from zeep.cache import SqliteCache
from zeep.transports import Transport
transport = Transport(cache=SqliteCache())
client = Client(
'http://www.webservicex.net/ConvertSpeed.asmx?WSDL',
transport=transport)

SOAPpy encoding error xml.parsers.expat.ExpatError

I'm using SOPApy to make a client for SOAP. Following code rises error.
import SOAPpy
wsdlFile = 'https://10.10.10.10/services/fwif?wsdl'
proxy = SOAPpy.WSDL.Proxy(wsdlFile)
Traceback (most recent call last):
File "run.py", line 28, in <module>
proxy = SOAPpy.WSDL.Proxy(wsdlFile)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/site-packages/SOAPpy/WSDL.py", line 83, in __init__
self.wsdl = reader.loadFromString(str(wsdlsource))
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/site-packages/wstools/WSDLTools.py", line 49, in loadFromString
return self.loadFromStream(StringIO(data))
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/site-packages/wstools/WSDLTools.py", line 28, in loadFromStream
document = DOM.loadDocument(stream)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/site-packages/wstools/Utility.py", line 645, in loadDocument
return xml.dom.minidom.parse(data)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/xml/dom/minidom.py", line 1918, in parse
return expatbuilder.parse(file)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/xml/dom/expatbuilder.py", line 928, in parse
result = builder.parseFile(file)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/xml/dom/expatbuilder.py", line 207, in parseFile
parser.Parse(buffer, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 6
On stackoverflow I found a similar problem When I consume wsdl using python, I get an xml.parsers.expat.ExpatError but don't understand how to apply it for SOAPpy.

Does nitrous.io support the endpoint library?

Developing a python project on the platform and attempting appengine endpoints.
import endpoints throws google.appengine.api.yaml_errors.EventError: the library "endpoints" is not supported. The full stack trace is below.
Traceback (most recent call last):
File "/home/action/.google_appengine/dev_appserver.py", line 182, in <module>
_run_file(__file__, globals())
File "/home/action/.google_appengine/dev_appserver.py", line 178, in _run_file
execfile(script_path, globals_)
File "/home/action/.google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 695, in <module>
main()
File "/home/action/.google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 688, in main
dev_server.start(options)
File "/home/action/.google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 525, in start
options.yaml_files)
File "/home/action/.google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 556, in __init__
server_configuration = ServerConfiguration(yaml_path)
File "/home/action/.google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 82, in __init__
self._yaml_path)
File "/home/action/.google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 272, in _parse_configuration
return appinfo_includes.ParseAndReturnIncludePaths(f)
File "/home/action/.google_appengine/google/appengine/api/appinfo_includes.py", line 63, in ParseAndReturnIncludePaths
appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
File "/home/action/.google_appengine/google/appengine/api/appinfo.py", line 1715, in LoadSingleAppInfo
listener.Parse(app_info)
File "/home/action/.google_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File "/home/action/.google_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: the library "endpoints" is not supported
in "./app.yaml", line 21, column 1
Start with a non-python project.
Download appengine for Linux python:
curl -O http://googleappengine.googlecode.com/files/google_appengine_1.8.9.zip
Unzip and export directory in ~/.bash_profile:
export PATH="$HOME/google_appengine:$PATH"
Build endpoint python app as described and run dev_appserver.py.
You can't view the Google APIs Explorer when launched from Nitrous.io, unless you port forward, but you can still use as a developing endpoint.

GAE can't generate discovery file

I upgraded my GAE SDK to Version 1.8.5 and cannot generate a discovery file anymore with endpointscfg.py gen_discovery_doc -o.-f rpc .../main.FlyFlap.APi
I get the errors below.
I tried to delete the file google_appengine/lib/cacerts/urlfetch_cacerts.txt and certs.txt like it is suggested here, but it didn't help. Does someone got same problems?
Traceback (most recent call last):
File "/usr/local/bin/endpointscfg.py", line 196, in <module>
run_file(__file__, globals())
File "/usr/local/bin/endpointscfg.py", line 192, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 472, in <module>
sys.exit(main(sys.argv))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 467, in main
args.callback(args)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 348, in _GenDiscoveryDocCallback
output_path, hostname=hostname)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 188, in GenDiscoveryDoc
service_configs = GenApiConfig(service_class_names, hostname=hostname)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 144, in GenApiConfig
module_name, base_service_class_name = service_class_name.rsplit('.', 1)
ValueError: need more than 1 value to unpack
updated osx and it works again.

xml.sax._exceptions.SAXParseException: /tmp/suds/suds-2582214468910359336.http:1:156: mismatched tag

i try to access web using python suds,the code is as follows.
#!/usr/bin/python
from suds.client import Client
url = 'http://192.168.80.1xx:8079/rpc/soap/jirasoapservice-v2?wsdl'
client = Client(url)
print client
on machine A with below character:ubuntu systemip adds is 192.168.1.xxpython version is 2.6.5can connect internet.have installed easy_install 0.6.10 and suds 0.3.7.another machine B:ubuntu systemip adds is 192.168.80.xxpython version is 2.6.5is offline.have installed setuptools-0.6c11-py2.6.egg and suds 0.3.7.on machine A the code above is ok while on machine B,there is some errors:
Traceback (most recent call last):
File "soaptest.py", line 7, in <module>
client = Client(url)
File "build/bdist.linux-x86_64/egg/suds/client.py", line 109, in __init__
File "build/bdist.linux-x86_64/egg/suds/wsdl.py", line 194, in __init__
File "build/bdist.linux-x86_64/egg/suds/wsdl.py", line 255, in build_schema
File "build/bdist.linux-x86_64/egg/suds/xsd/schema.py", line 90, in load
File "build/bdist.linux-x86_64/egg/suds/xsd/schema.py", line 280, in open_imports
File "build/bdist.linux-x86_64/egg/suds/xsd/schema.py", line 280, in open_imports
File "build/bdist.linux-x86_64/egg/suds/xsd/schema.py", line 280, in open_imports
File "build/bdist.linux-x86_64/egg/suds/xsd/schema.py", line 280, in open_imports
File "build/bdist.linux-x86_64/egg/suds/xsd/schema.py", line 277, in open_imports
File "build/bdist.linux-x86_64/egg/suds/xsd/sxbasic.py", line 608, in open
File "build/bdist.linux-x86_64/egg/suds/xsd/sxbasic.py", line 626, in download
File "build/bdist.linux-x86_64/egg/suds/sax/parser.py", line 134, in parse
File "/usr/lib/python2.6/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python2.6/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib/python2.6/xml/sax/expatreader.py", line 211, in feed
self._err_handler.fatalError(exc)
File "/usr/lib/python2.6/xml/sax/handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: /tmp/suds/suds-2582214468910359336.http:1:156: mismatched tag

Categories

Resources