[英]python suds UsernameToken
Code: 码:
security = Security()
token = UsernameToken('b77a5c561934e089', 'kmfHkNZyn1U/pGAiY3+h0BoHdKI=')
security.tokens.append(token)
client.set_options(wsse=security)
My problem is this one: when including UsernameToken, i receive this kind of header: 我的问题是这个:当包含UsernameToken时,我会收到这种标题:
<SOAP-ENV:Header>
<wsse:Security mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>b77a5c561934e089</wsse:Username>
<wsse:Password>kmfHkNZyn1U/pGAiY3+h0BoHdKI=</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
But what i need is the response to this requirement on web service: 但我需要的是对Web服务的这一要求的响应:
<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssUsernameToken10 />
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SignedSupportingTokens>
How can i do this with suds? 我怎么能用肥皂水呢? Searched whole internet, but didnt find a solution. 搜索了整个互联网,但没有找到解决方案。
Your code is a SOAP generic solution. 您的代码是SOAP通用解决方案。 Your web service seems to require a custom response. 您的Web服务似乎需要自定义响应。
I presume your authentication does not work? 我认为你的身份验证不起作用?
Try to marshall
your response into your requester class
. 尝试将您的回复marshall
到请求者class
。 This plugin allows you to modify your soap
envelope. 这个插件允许你修改你的soap
信封。 You can add your own attributes. 您可以添加自己的属性。
class MyRequesterClass(object):
class _myServiceMarshalled(MessagePlugin):
def marshalled(self, context):
commons.set_service_common_header(context, "yourService")
body = context.envelope.getChild('Body')
service = body.getChild("childWhereYouWantAddYourCustomXML")
service.attributes.append(Attribute("sp:IncludeToken", "http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"))
etc, etc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.