如何在python中通过Soap发送文件? [英] How to send a file through Soap in python?

查看:20
本文介绍了如何在python中通过Soap发送文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 python 中通过 SOAP(从 SOAP 客户端到 SOAP 服务器)发送一个 zip 文件.

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

阅读this SO question,我选择使用 suds 作为我的 python 客户端.但是根据this,suds 不支持发送附件.提供了一种方法来规避该问题,但我无法使其正常工作.我对我应该提供的参数感到困惑.

Following the reading of this SO question, I choose to use suds as my python client. But according to this, suds do not support sending attachment. A method is given to circumvent the problem but I've not been able to make it work. I'm puzzled over what I'm supposed to give as parameters.

有人知道如何在python中通过Soap发送文件吗?

Anyone know how to send a file through Soap in python ?

如果需要,我将切换到另一个 SOAP 客户端库.

If needed I'll switch to another SOAP client library.

推荐答案

下载提供的包装器,然后下载您通常会说的类似...

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

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

...而是做...

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

其中 binaryParam 是soap_attachements.py 所期望的类型.例如,如果您想发送 png 图像,我认为(从未这样做过)您会这样做:

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)

这篇关于如何在python中通过Soap发送文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆