How to send a file through Soap in python?

前端 未结 3 969
一个人的身影
一个人的身影 2020-12-10 22:36

I want to send a zip file through SOAP (from a SOAP client to a SOAP server) in python.

Following the reading of this SO question, I choose to use suds as my python

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 23:19

    Download the provided wrapper, and then where you would normally say something like...

    client.service.fooMethod(fooParam1,fooParam2,...)
    

    ...instead do...

    soap_attachments.with_soap_attachment(client.service.fooMethod,binaryParam,fooParam1,fooParam2,...)
    

    Where binaryParam is of the type expected by soap_attachements.py. For example, if you wanted to send a png image I think (never done this) you would do:

    imageFile = open('imageFile.png','rb')
    imageData = imageFile.read()
    mimeType = 'image/png'
    binaryParam = (imageData, uuid.uuid4(), mimeType)
    

提交回复
热议问题