Python AXL/SOAP w.齐普如何避免重复的字典键? [英] Python AXL/SOAP w. Zeep. How to avoid duplicate dictionary keys?

查看:103
本文介绍了Python AXL/SOAP w.齐普如何避免重复的字典键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了这个请求:

client.updateLdapAuthentication(**{'authenticateEndUsers': authenticateEndUsers, 'distinguishedName': distinguishedName, 'ldapPassword': ldapPassword, 'userSearchBase': userSearchBase, 'servers':{'server': {'hostName': '172.20.23.230', 'ldapPortNumber': '3268', 'sslEnabled': 'false'}}})

这导致了预期的请求:

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
    <ns0:updateLdapAuthentication xmlns:ns0="http://www.cisco.com/AXL/API/11.5">
        <authenticateEndUsers>true</authenticateEndUsers>
        <distinguishedName>CN=DIRSYNC USER,CN=Users,DC=lab,DC=local</distinguishedName>
        <ldapPassword>text</ldapPassword>
        <userSearchBase>text</userSearchBase>
        <servers>
            <server>
                <hostName>172.20.23.230</hostName>
                <ldapPortNumber>3268</ldapPortNumber>
                <sslEnabled>true</sslEnabled>
            </server>
        </servers>
    </ns0:updateLdapAuthentication>
</soap-env:Body>

我正在努力的是使用两个服务器条目来形成一个请求,如下所示:

What I'm struggeling with is forming a request with two server entries like this:

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
    <ns0:updateLdapAuthentication xmlns:ns0="http://www.cisco.com/AXL/API/11.5">
        <authenticateEndUsers>true</authenticateEndUsers>
        <distinguishedName>CN=DIRSYNC USER,CN=Users,DC=lab,DC=local</distinguishedName>
        <ldapPassword>text</ldapPassword>
        <userSearchBase>text</userSearchBase>
        <servers>
            <server>
                <hostName>172.20.23.230</hostName>
                <ldapPortNumber>3268</ldapPortNumber>
                <sslEnabled>true</sslEnabled>
            </server>
            <server>
                <hostName>172.20.23.250</hostName>
                <ldapPortNumber>3268</ldapPortNumber>
                <sslEnabled>true</sslEnabled>
            </server>
        </servers>
    </ns0:updateLdapAuthentication>
</soap-env:Body>

我通过python -mzeep检查了WSDL.这是相关行:

I checked the WSDL via python -mzeep. This is the relevant line:

updateLdapAuthentication(authenticateEndUsers: ns0:boolean, distinguishedName: ns0:String128, ldapPassword: ns0:String128, userSearchBase: ns0:String255, servers: {server: {hostName: ns0:String128, ldapPortNumber: , sslEnabled: ns0:boolean}[]}) -> return: ns0:return, sequence: xsd:unsignedLong

所以,我形成了这样的请求:

So, I formed a request like this:

client.updateLdapAuthentication(**{'authenticateEndUsers': authenticateEndUsers, 'distinguishedName': distinguishedName, 'ldapPassword': ldapPassword, 'userSearchBase': userSearchBase, 'servers':
 [{'server': {'hostName': '172.20.23.230',
             'ldapPortNumber': '3268',
             'sslEnabled': 'false'}},
 {'server': {'hostName': '172.20.23.250',
             'ldapPortNumber': '3268',
             'sslEnabled': 'false'}}]})

它仍然有效,但是忽略第二个服务器条目.有没有人暗示如何做到这一点?

It still works, but ignores the second server entry. Has anyone some hints how to do this?

推荐答案

我引用updateLdapAuthentication的方式是,您没有指定字典列表,而是指定了一个包含键server的字典,其中字典. 因此,而不是

The way I your reference for updateLdapAuthentication is that you do not specify a list of dictionaries but one dictionary with a key server which has a list of dictionaries. So instead of

[{'server': {'hostName': '172.20.23.230',
             'ldapPortNumber': '3268',
             'sslEnabled': 'false'}},
 {'server': {'hostName': '172.20.23.250',
             'ldapPortNumber': '3268',
             'sslEnabled': 'false'}}]

尝试

{'server': [{'hostName': '172.20.23.230', 'ldapPortNumber': '3268', 'sslEnabled': 'false'},
            {'hostName': '172.20.23.250', 'ldapPortNumber': '3268', 'sslEnabled': 'false'}}]

这篇关于Python AXL/SOAP w.齐普如何避免重复的字典键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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