Python 使用sud向SOAP web服务传递多个参数

Python 使用sud向SOAP web服务传递多个参数,python,soap,Python,Soap,我想使用一个PHP SOAP Web服务,它需要身份验证。但是,用户名和密码不需要在HTTP头中传递,而是作为SOAP参数传递。我只有一个运行查询的PHP(工作)示例: $soap_client->getCurrentOrderCustomers(array("user" => 'root', "password" => 'toor')); 这可以正常工作,并创建以下请求: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schema

我想使用一个PHP SOAP Web服务,它需要身份验证。但是,用户名和密码不需要在HTTP头中传递,而是作为SOAP参数传递。我只有一个运行查询的PHP(工作)示例:

$soap_client->getCurrentOrderCustomers(array("user" => 'root', "password" => 'toor'));
这可以正常工作,并创建以下请求:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="https://example.com/webservice/interface_bi.php" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Body>
      <ns1:getCurrentOrderCustomers>
         <param0 xsi:type="ns2:Map">
            <item>
               <key xsi:type="xsd:string">user</key>
               <value xsi:type="xsd:string">root</value>
            </item>
            <item>
               <key xsi:type="xsd:string">password</key>
               <value xsi:type="xsd:string">toor</value>
            </item>
         </param0>
      </ns1:getCurrentOrderCustomers>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
这也是:

result = ws_client.service.getCurrentOrderCustomers(user='root',password='toor')
但是,这两种方法都会导致以下请求,没有任何参数:

<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="https://example.com/webservice/interface_bi.php" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns2:getCurrentOrderCustomers/>
   </ns1:Body>
</SOAP-ENV:Envelope>


如果有人建议如何将参数传递给webservice函数以获得所需的请求,我将不胜感激。提前感谢。

我想-SOAP服务WSDL告诉我们如何将参数传递给SOAP方法。 我尝试了以下代码:Python和SOAP调用,使用suds对我来说很好

第4行-打印客户端显示所有带参数的soap方法

from suds.client import Client

url="http://www.dneonline.com/calculator.asmx?wsdl"
client = Client(url)

print client ## shows the details of this service

result = client.service.Multiply(10, 5)
print result
下面是上述脚本的输出

@ -如果您共享您的WSDL,我可以进一步调查

from suds.client import Client

url="http://www.dneonline.com/calculator.asmx?wsdl"
client = Client(url)

print client ## shows the details of this service

result = client.service.Multiply(10, 5)
print result