【发布时间】:2020-10-26 10:22:45
【问题描述】:
当我在 SOAPUI 中查看原始请求时,我在 <soapenv:Header> 部分中得到 = wsse:Security soapenv:mustUnderstand="1"。使用 zeep 和 python 执行此操作时,我在发送到服务器的请求中看不到这一点 - 我在应用程序日志中遇到了安全问题
from zeep import Client
from zeep.transports import Transport
from zeep import xsd
from zeep.wsse.username import UsernameToken
from zeep.wsse.utils import get_security_header
from requests import Session
request_data = {
'idNumber': 'someID',
'encryptedPin': 'encPin0101='
}
header_value = {
"wsse":{
"mustUnderstand":'1'
}
}
wsdl = 'http://someURL/AuthenticationWS?WSDL'
# session = Session()
# session.verify = True
# transport = Transport(session=session,
# operation_timeout=10)
cl = Client(wsdl=wsdl,
wsse=UsernameToken('username', 'password', use_digest=True))
def send_request(client, data):
return client.service.authenticateCustomer(data)
node = cl.create_message(cl.service, 'authenticateCustomer',
idNumber='someID',
encryptedPin='encPin=')
from lxml import etree
print('###########')
print(etree.tostring(node))
print('###########')
print(send_request(cl, request_data))
第一个打印出来的作品,我看到了我需要的信息除了 mustunderstand=1 第二个打印错误 - 我得到“发生故障”,应用程序日志给出了与安全相关的错误,让我认为这是必须理解的事情,我尝试了不同的事情
我已尝试使用soapheader 执行此操作,如这些位置中所述,但没有成功:
How do I add attributes to header authentication in Zeep?
添加会话\传输的东西没有弹出我需要的标题。我正忙着看呢
https://pydoc.net/zeep/2.5.0/zeep.wsse.signature/
为了理解 `get_security_header` 的事情,但我没有赢得这个:( 我看过的其他资源:
https://stackoverflow.com/questions/62924433/zeep-with-complex-header
https://docs.python-zeep.org/en/master/headers.html
https://stackoverflow.com/questions/44330748/how-to-comply-with-policy-defined-in-wsdl
【问题讨论】: