Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suds.MethodNotFound: Method not found: 'ATWS.ATWSSoap.__len__' #79

Open
ewanhamilton opened this issue Apr 19, 2020 · 2 comments
Open

Comments

@ewanhamilton
Copy link

ewanhamilton commented Apr 19, 2020

Windows 10 x64
Python 3.8.0
ATWS 5.5

Example code. Have tried just import atws and the full import. Same exact error on both.

import atws
import atws.monkeypatch.attributes

username = "x"
password = "x"

at = atws.connect(username=username, password=password, apiversion=1.6,
                  integrationcode='x')

query = atws.Query('Ticket')
query.WHERE('id',query.GreaterThan,1)

print(query.pretty_print())

tickets = at.query(query)

Terminal output:

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
runfile('C:/Users/Ewan/PycharmProjects/game/base.py', wdir='C:/Users/Ewan/PycharmProjects/game')
Suds version (0.6) not ideal. Please use 0.7
<?xml version="1.0" ?>
<queryxml>
	<entity>Ticket</entity>
	<query>
		<field>
			id
			<expression op="GreaterThan">1</expression>
		</field>
	</query>
</queryxml>
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3\plugins\python-ce\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 274, in frame_vars_to_struct
    value = var_to_struct(v, str(k), evaluate_full_value=eval_full_val)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3\plugins\python-ce\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 358, in var_to_struct
    elif hasattr(v, '__len__') and not is_string(v):
  File "C:\Users\Ewan\PycharmProjects\game\venv\lib\site-packages\atws\connection.py", line 233, in __getattr__
    return getattr(self.client.service,attr)
  File "C:\Users\Ewan\PycharmProjects\game\venv\lib\site-packages\suds\client.py", line 283, in __getattr__
    return getattr(port, name)
  File "C:\Users\Ewan\PycharmProjects\game\venv\lib\site-packages\suds\client.py", line 387, in __getattr__
    return getattr(m, name)
  File "C:\Users\Ewan\PycharmProjects\game\venv\lib\site-packages\suds\client.py", line 478, in __getattr__
    return self[name]
  File "C:\Users\Ewan\PycharmProjects\game\venv\lib\site-packages\suds\client.py", line 491, in __getitem__
    raise MethodNotFound(qn)
suds.MethodNotFound: Method not found: 'ATWS.ATWSSoap.__len__'
Unexpected error, recovered safely.

I'm able to successfully query it without using a module for it. Such as:

from requests import Request, Session
import base64
import sys

username = "x"
password = "x"

query = "<getThresholdAndUsageInfo xmlns='http://autotask.net/ATWS/v1_6/'></getThresholdAndUsageInfo>"

url = "https://webservices4.autotask.net/atservices/1.6/atws.asmx"
body = """<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
    <soap:Header>
        <AutotaskIntegrations xmlns='http://autotask.net/ATWS/v1_6/'>
            <IntegrationCode>x</IntegrationCode>
        </AutotaskIntegrations>
    </soap:Header>
    <soap:Body>"""
body += query
body += """</soap:Body>
</soap:Envelope>"""
headers = {
    'Content-Type': "text/xml; charset=utf-8",
    'Content-Length': str(sys.getsizeof(body)),
    'Authorization': "Basic " + bytes.decode(base64.b64encode(bytes(username + ":" + password, "utf-8"))),
    'Accept': "application/json"
}
s = Session()
req = Request('POST', url, data=body, headers=headers)
prepped = req.prepare()
resp = s.send(prepped)
print(resp.content)

Returns

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
runfile('C:/Users/Ewan/PycharmProjects/game/base.py', wdir='C:/Users/Ewan/PycharmProjects/game')
b'<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><getThresholdAndUsageInfoResponse xmlns="http://autotask.net/ATWS/v1_6/"><getThresholdAndUsageInfoResult><ReturnCode>1</ReturnCode><EntityResults /><EntityResultType /><Errors /><EntityReturnInfoResults><EntityReturnInfo><EntityId>0</EntityId><DatabaseAction>None</DatabaseAction><DuplicateStatus><Found>false</Found><Ignored>false</Ignored></DuplicateStatus><Message>ThresholdOfExternalRequest: 10000; TimeframeOfLimitation: 60; numberOfExternalRequest: 293;</Message></EntityReturnInfo></EntityReturnInfoResults></getThresholdAndUsageInfoResult></getThresholdAndUsageInfoResponse></soap:Body></soap:Envelope>'
@MattParr
Copy link
Owner

MattParr commented Apr 20, 2020 via email

@VCJames
Copy link

VCJames commented Jun 25, 2020

I experience(d) this issue as well. It only happens when running in PyCharm and IIRC reverting to 3.7 did resolve the issue for me. It has to do with the variable debugger and ultimately the functionality wasn't impacted. I continued to use 3.8.

YMMV?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants