加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python suds UsernameToken

发布时间:2020-12-20 13:12:24 所属栏目:Python 来源:网络整理
导读:码: security = Security()token = UsernameToken('b77a5c561934e089','kmfHkNZyn1U/pGAiY3+h0BoHdKI=')security.tokens.append(token)client.set_options(wsse=security) 我的问题是这个:当包含UsernameToken时,我会收到这种标题: SOAP-ENV:Header wsse:
码:

security = Security()
token = UsernameToken('b77a5c561934e089','kmfHkNZyn1U/pGAiY3+h0BoHdKI=')
security.tokens.append(token)
client.set_options(wsse=security)

我的问题是这个:当包含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>

但我需要的是对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>

我怎么能用肥皂水呢?搜索了整个互联网,但没有找到解决方案.

解决方法

您的代码是SOAP通用解决方案.您的Web服务似乎需要自定义响应.

我认为你的身份验证不起作用?

尝试将您的回复编组到请求者类中.这个plugin允许你修改你的肥皂信封.
您可以添加自己的属性.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读