问题描述
我正在尝试在 python 库
我的问题是,如何访问信封内的数据(我需要rowOrders,部分显示在屏幕上)
我也遇到了同样的问题.所以我就是这样做的.这不是最好的方法,但它可以是一个开始,我希望制造商原谅我.另外,我刚刚开始学习python.
在此处克隆 zeep 项目:https://github.com/mvantellingen/python-zeep并转到该文件夹.
在transports.py中,在构造函数(_ init _)中添加这一行:
self.response = ''
然后在方法 post 中,在返回响应之前,添加以下行:
self.response = 响应
在此之后,通过执行
来构建包python setup.py install
这应该在你的 virtualenv 中(如果你正在使用)
所以在你的代码中,你可以打印
打印 my_transport.response.content
希望能帮到你
I am trying to work with wsdl with the help of python library zeep. It works fine, but i can't find out how can I get data from request.
My code:
# encoding=utf-8
from requests.auth import HTTPBasicAuth # or HTTPDigestAuth, or OAuth1, etc.
from zeep import Client
from zeep import helpers
from zeep.transports import Transport
import logging.config
logging.config.dictConfig({
'version': 1,
'formatters': {
'verbose': {
'format': '%(name)s: %(message)s'
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'loggers': {
'zeep.transports': {
'level': 'DEBUG',
'propagate': True,
'handlers': ['console'],
},
}
})
wsdl = 'wsdl_url'
user = 'login'
password = 'password'
my_transport = Transport(http_auth=HTTPBasicAuth(user, password))
client = Client(
wsdl, transport=my_transport
)
result = client.service.FunctionName(...)
print result
As a result, i get this:
{
'schema': <Schema(location=None)>,
'_value_1': <Element {urn:schemas-microsoft-com:xml-diffgram- v1}diffgram at 0x104ec0098>
}
Obviously, it is not what I want. Thanks to logging, I can see, that actually I get the needed information with envelope:
My question is, how can I access the data inside the envelope (I need rowOrders, which are partly displayed on screen)
I also faced the same problem. So this is how I did it. This is not the best way to do it, but it can be a start and I wish the maker forgives me.Also, I am just starting to learn python.
clone the zeep project here:https://github.com/mvantellingen/python-zeepand go to that folder.
in transports.py, add this line in the constructor (_ init _):
self.response = ''
and then in the method post, before returning the response, add this line:
self.response = response
after this, build the package by executing
python setup.py install
this should be in your virtualenv (if you are using one)
so in your code, you can print
print my_transport.response.content
hope this helps
这篇关于从肥皂信封 zeep 中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!