benkonrath / transip-api

Python implementation for the TransIP API
https://transip-api.readthedocs.io/en/latest/
MIT License
23 stars 23 forks source link

TypeNotFound: Type not found: '(array, http://www.w3.org/2001/XMLSchema, )' #60

Closed baskoopmans closed 4 years ago

baskoopmans commented 4 years ago

We run the following command:

$ transip-api -s --domain-name example.org -l <username> --api-key /transip-rsa.key

And get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/transip-api", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/transip/transip_cli.py", line 102, in main
    domain_service = DomainService(args.loginname, args.api_key_file)
  File "/usr/local/lib/python2.7/site-packages/transip/service/domain.py", line 12, in __init__
    super(DomainService, self).__init__('DomainService', *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/transip/client.py", line 90, in __init__
    self.soap_client = SudsClient(self.url, doctor=doc, **suds_kwargs)
  File "/usr/local/lib/python2.7/site-packages/suds/client.py", line 122, in __init__
    sd = ServiceDefinition(self.wsdl, s)
  File "/usr/local/lib/python2.7/site-packages/suds/servicedefinition.py", line 58, in __init__
    self.addports()
  File "/usr/local/lib/python2.7/site-packages/suds/servicedefinition.py", line 86, in addports
    method = (m.name, binding.param_defs(m))
  File "/usr/local/lib/python2.7/site-packages/suds/bindings/rpc.py", line 35, in param_defs
    return self.bodypart_types(method)
  File "/usr/local/lib/python2.7/site-packages/suds/bindings/binding.py", line 379, in bodypart_types
    raise TypeNotFound(query.ref)
suds.TypeNotFound: Type not found: '(array, http://www.w3.org/2001/XMLSchema, )'

Any ideas why this happens all of the sudden? Did TransIP change their API?

The following packages are installed (transip==2.0.0):

acme==1.3.0
appdirs==1.4.3
certbot==1.3.0
certbot-dns-transip==0.2.5
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
ConfigArgParse==1.0
configobj==5.0.6
configparser==4.0.2
contextlib2==0.6.0.post1
cryptography==2.8
distlib==0.3.0
distro==1.4.0
enum34==1.1.9
filelock==3.0.12
funcsigs==1.0.2
idna==2.9
importlib-metadata==1.5.0
importlib-resources==1.0.2
ipaddress==1.0.23
josepy==1.3.0
mock==3.0.5
parsedatetime==2.5
pathlib2==2.3.5
pycparser==2.20
pyOpenSSL==19.1.0
pyRFC3339==1.1
pytz==2019.3
requests==2.23.0
requests-toolbelt==0.9.1
scandir==1.10.0
six==1.14.0
suds-jurko==0.6
transip==2.0.0
typing==3.7.4.1
urllib3==1.25.8
virtualenv==20.0.7
zipp==1.2.0
zope.component==4.6
zope.deferredimport==4.3.1
zope.deprecation==4.4.0
zope.event==4.4
zope.hookable==5.0.0
zope.interface==4.7.2
zope.proxy==4.3.3
olafz commented 4 years ago

TransIP changed their API on March 5th, 2020: https://www.transip.nl/nieuws/de-nieuwe-transip-rest-api-is-live/

Voor onze nieuwe API zijn we overgestapt van SOAP naar het REST-protocol. Dit houdt onder andere in dat de API voortaan JSON in plaats van XML returnt

Translation: the new API moved from SOAP to REST. This means - for example - that the API now returns JSON instead of XML.

Re https://github.com/github/octodns/issues/512

marklagendijk commented 4 years ago

It may be that they moved the api endpoint. I'll contact TransIP about this.

marklagendijk commented 4 years ago

See the discussion in #62 Apparently TransIP had made a breaking change on the SOAP API, and they are rolling out a fix.

benkonrath commented 4 years ago

Version 2.1.0 has just been released to fix this problem. Thanks for all the help on this!

KajdeMunter commented 4 years ago

I'm still experiencing this issue..

$ pip freeze | grep transip
transip==2.1.1
$ transip-api -s --domain-name <domain> -l <username> --api-key /transip.key

Traceback (most recent call last):
  File "/usr/local/bin/transip-api", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/transip/transip_cli.py", line 102, in main
    domain_service = DomainService(args.loginname, args.api_key_file)
  File "/usr/local/lib/python2.7/dist-packages/transip/service/domain.py", line 12, in __init__
    super(DomainService, self).__init__('DomainService', *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/transip/client.py", line 103, in __init__
    self.soap_client = SudsClient(self.url, doctor=doc, plugins=[WSDLFixPlugin()], **suds_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 122, in __init__
    sd = ServiceDefinition(self.wsdl, s)
  File "/usr/local/lib/python2.7/dist-packages/suds/servicedefinition.py", line 58, in __init__
    self.addports()
  File "/usr/local/lib/python2.7/dist-packages/suds/servicedefinition.py", line 86, in addports
    method = (m.name, binding.param_defs(m))
  File "/usr/local/lib/python2.7/dist-packages/suds/bindings/rpc.py", line 35, in param_defs
    return self.bodypart_types(method)
  File "/usr/local/lib/python2.7/dist-packages/suds/bindings/binding.py", line 379, in bodypart_types
    raise TypeNotFound(query.ref)
suds.TypeNotFound: Type not found: '(array, http://www.w3.org/2001/XMLSchema, )'

Anyone have any idea why? I've tried reinstalling the package.

benkonrath commented 4 years ago

It looks like you have the fixed version:

self.soap_client = SudsClient(self.url, doctor=doc, plugins=[WSDLFixPlugin()], **suds_kwargs)

I guess it's not working. Anybody else see this?

maikelpoot commented 4 years ago

Also getting the Type not found error with transip==2.1.1

maikelpoot commented 4 years ago

Tried to debug the issue, looks like a typo in https://api.transip.nl/wsdl/?service=DomainService

There is a message block named TransferWithOwnerChangeWithExtraContactFieldsRequest with: <part name="extraContactFields" type="xsd:array"/>

Where the sister block TransferWithoutOwnerChangeWithExtraContactFieldsRequest and others have: <part name="extraContactFields" type="tns:ArrayOfstring"/>

Problem is that sudsClient loads plugins after loading (and crashing on) the wsdl. So we can't fix it.

# suds/client.py line: 114-117
reader = DefinitionsReader(options, Definitions)
self.wsdl = reader.open(url)       <-- Exception happens in here 
plugins = PluginContainer(options.plugins)
plugins.init.initialized(wsdl=self.wsdl)
KajdeMunter commented 4 years ago

Okay, so any (temporary) workaround suggestions?

marklagendijk commented 4 years ago

I would advise contacting TransIP with a message saying:

benkonrath commented 4 years ago

I just tested this command with Python 3.8 and transip-api 2.1.2 (just released) and it seems to be working.

transip-api -s --domain-name example.org -l <username> --api-key /transip-rsa.key

@maikelpoot @KajdeMunter Do you have an example command that's not working?

maikelpoot commented 4 years ago

Upgrading to 2.1.2 seems to fix it indeed: (python2.7)

$ transip-api -s --domain-name example.org -l <username> --api-key /transip-rsa.key

ValueError: Could not deserialize key data.

$ pip install --upgrade transip

Successfully uninstalled transip-2.1.1 Successfully installed transip-2.1.2

$ transip-api -s --domain-name example.org -l <username> --api-key /transip-rsa.key

[(DnsEntry){ name = "*" expire = 300 type = "A" .....

KajdeMunter commented 4 years ago

Yeah. Seems to work for me now as well! The fix for 2.1.2 was for ValueError: Could not deserialize key data which I had in 2.1.1 after first experiencing Type not found: '(array, http://www.w3.org/2001/XMLSchema, )'. Maybe TransIP changed their API?

benkonrath commented 4 years ago

Maybe TransIP changed their API?

My guess is that's exactly what happened.

Thanks to everybody who's helped fix the few issues we've hit recently!