python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

Need help on using using zeep to upload file

Open rainierpineda2 opened this issue 5 years ago • 4 comments

When I use SoapUI I have no issues uploading the file.

import zeep
from zeep import Client, Settings, Transport
WSDL = "http://example.casdm.com:8080/axis/services/USD_R11_WebService?wsdl"
SETTINGS = Settings(strict=False, xml_huge_tree=True)
client = Client(wsdl=WSDL, settings=SETTINGS)
 
def attach_file_to_chg(session_id, chghandle, filename):
        try:
            payload = {
                'sid': session_id,
                'repositoryHandle': 'doc_rep:1002',
                'objectHandle': str(chghandle),
                'description': 'This is an attachment',
                'fileName': (str(filename), open(str(filename), "rb"))
            }
            response = client.service.createAttachment(**payload)
            #print('response: '+str(response))
            return response
        except zeep.exceptions.Fault as e:
            raise Exception(str(e))
        except Exception as e:
            raise Exception(str(e))

attresult = attach_file_to_chg(88887777, "chg:12344321", "testme.csr")

I get the following errors:

Traceback (most recent call last):
  File "/home/u1163139/casdm/casdm.py", line 180, in attach_file_to_chg
    response = client.service.createAttachment(**payload)
  File "/home/u1163139/casdm/venv/lib64/python3.6/site-packages/zeep/proxy.py", line 45, in __call__
    kwargs,
  File "/home/u1163139/casdm/venv/lib64/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 130, in send
    return self.process_reply(client, operation_obj, response)
  File "/home/u1163139/casdm/venv/lib64/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 195, in process_reply
    return self.process_error(doc, operation)
  File "/home/u1163139/casdm/venv/lib64/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 299, in process_error
    detail=fault_node.find("detail"),
zeep.exceptions.Fault: Error - could not perform the operation, policy limit exceeded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run_casdm.py", line 78, in <module>
    attresult = attach_file_to_chg(sid, chg_handle, filename)
  File "/home/u1163139/casdm/casdm.py", line 184, in attach_file_to_chg
    raise Exception(str(e))
Exception: Error - could not perform the operation, policy limit exceeded

rainierpineda2 avatar Apr 07 '20 22:04 rainierpineda2

I don't know if you managed to sort this issue in the end, but the error message suggests that you've exceeded a usage limit on the API.

If you cannot change the request limits, then try it again after waiting for the quota to refresh.

da1910 avatar Sep 15 '20 22:09 da1910

Thank you. I was able to sort this out by using another library that properly processes file attachments using SOAP as transport. It could be true that the policy our CASD have does not even allow for an attachment like this in this manner. When I attach via SoapUI tool, it always works so I concluded that is the a problem with the transport used.

On Sep 15, 2020, at 6:49 PM, Doug Addy [email protected] wrote:

I don't know if you managed to sort this issue in the end, but the error message suggests that you've exceeded a usage limit on the API.

If you cannot change the request limits, then try it again after waiting for the quota to refresh.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mvantellingen/python-zeep/issues/1073#issuecomment-693019470, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHM334WA7FN4ZYL6NQTRRGDSF7VORANCNFSM4MDPDDXQ.

rainierpineda2 avatar Sep 16 '20 14:09 rainierpineda2

I'm glad you found a solution that worked for you!

da1910 avatar Sep 16 '20 14:09 da1910

@rainierpineda2 I'm having the same problem, which library did you use?

aurtasun avatar Apr 05 '24 09:04 aurtasun