喜欢用SimpleSoapySAP的客户端来诱骗用户吗?

2024-06-26 13:43:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在编写一系列脚本来自动执行ISPConfig(web托管控制台)上的任务。你不需要知道,真的,因为这个问题是关于形成XML的。因为。。。原因。。。我想用Python而不是PHP来完成这个任务。我的第一个脚本的目的是为给定的域创建新的邮箱,我有一些现有的PHP代码可以使用。在

一切进展顺利。尽管有一些简洁的文档,但我已经到了这样一个地步:我的脚本正在与API通信,并通过如下所示的pysimplesoap调用发送参数。在

client = pysimplesoap.client.SoapClient(location=SOAP_LOCATION,
                                        namespace=SOAP_URI, trace=True)
response = client.login(username=console_login, password=console_pass)
session_id = str(response.children().children().children())
params = {
          'server_id': 1,
          'email': mailbox.mail_id,
          'login': mailbox.mail_id,
          'password': mailbox.mail_pass,
           # plus more params here ...
         }
response = client.mail_user_add(session=session_id,
                                client=client_id, params=params)
client.logout(session=session_id)

没有抛出任何错误,登录和注销都有效,但是通过ISPConfig控制台检查,会创建一个完全空白的邮箱。同时,PHP中相同的调用会生成填充的邮箱。在

在让两种语言在屏幕上显示各自的响应和请求之后,问题就变得非常清楚了。。。在

对服务器的Python SOAP请求(使用上面的代码)

^{pr2}$

PHP对服务器的SOAP请求

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://66.212.164.9:8080/remote/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<SOAP-ENV:Body>
<ns1:mail_user_add>
<param0 xsi:type="xsd:string">b0048bd548a3062a3dbcbc49bc74a39c</param0>
<param1 xsi:type="xsd:int">0</param1>
<param2 xsi:type="ns2:Map">
    <item>
        <key xsi:type="xsd:string">server_id</key>
        <value xsi:type="xsd:int">1</value>
    </item>
    <item>
        <key xsi:type="xsd:string">email</key>
        <value xsi:type="xsd:string">someone@domain.com</value>
    </item>
    <item>
        <key xsi:type="xsd:string">login</key>
        <value xsi:type="xsd:string">someone@domain.com</value>
    </item>
    <item> ... </item>
</param2>
</ns1:mail_user_add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

嗯。该死。我应该如何让pysimplesoap以上述格式创建请求,以便API可以正确地使用它们?在

(除非出现这种情况,否则我使用的是https://github.com/pysimplesoap/pysimplesoap也是python3中更新的pysimplesoap 1.16)

很不幸,ISPConfig似乎没有提供我刚刚开始阅读的神秘文档WSDL。Suko很可能是个很重要的客户。 没有引用WSDL:http://bugtracker.ispconfig.org/index.php?do=details&task_id=1273 Cite不能使用肥皂水:https://lists.fedoraproject.org/pipermail/suds/2010-February/000702.html


Tags: keyorgenvclientidhttpstringtype