gpt4 book ai didi

Python AXL/SOAP w。啧啧。如何避免重复的字典键?

转载 作者:行者123 更新时间:2023-12-04 13:03:03 25 4
gpt4 key购买 nike

我写了这个请求:

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>

我正在努力使用两个服务器条目形成一个请求,如下所示:
<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。这是相关的行:
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

所以,我形成了这样的请求:
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'}}]})

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

最佳答案

我的方式你引用updateLdapAuthentication是您没有指定字典列表,而是指定一个带有键 server 的字典。它有一个字典列表。
所以代替

[{'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。啧啧。如何避免重复的字典键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49847976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com