我写了这个请求:
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'}}]})
它仍然有效,但忽略了第二个服务器条目。有没有人提示如何做到这一点?
答案 0 :(得分:0)
我对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'}}]