SOAP客户端,WSDL,Python
我有一个SOAP服务,配有WSDL文件,还有一个用PHP写的客户端。
PHP客户端:
<?php
$client = new SoapClient('https://xx.xx.xx.xx/service/?wsdl');
$headers = array();
$headers[] = new SoapHeader('http://mfisoft.ru/auth','Login','admin');
$headers[] = new SoapHeader('http://mfisoft.ru/auth','Password','admin');
$client->__setSoapHeaders($headers);
$table_hi = $client->getTableByTitle('Blocked numbers');
$row_data = array(
array(
array(
'name' => 'prfx',
'value' => '55555555'
),
array(
'name' => 'blocking_time',
'value' => '20140306185014'
)
)
);
$rowset=$client->insertRowset($table_hi, $row_data);
?>
但是我需要把它改写成Python的版本。我尝试过用suds和pysimplesoap这两个库。
from suds.client import Client
url = 'http://localhost/service/?wsdl'
client = Client(url)
我不太明白怎么在Python中写出类似的程序,特别是这些代码行。
$headers[] = new SoapHeader('http://mfisoft.ru/auth','Login','admin');
$headers[] = new SoapHeader('http://mfisoft.ru/auth','Password','admin');
$client->__setSoapHeaders($headers);
我在suds的文档里没有找到相关信息。我需要你的帮助。
提前谢谢你。
附言:抱歉我的英语不好。
再附言:
我需要把这个PHP客户端改写成Python客户端。
1 个回答
0
请原谅我格式上的问题……使用suds客户端进行设置和连接的正确方法如下。如果你想要服务器部分,我不太确定你的问题……我可能能帮忙,但我在Python中从来没有做过这方面的事情。
client = suds.client.Client.(self,url=wsdl_url,
doctor=schema_doctor,
username=username)
try:
# This will throw an Exception if the wsdl_url is bad
# and will return False if the authentication fails
if not client.service.Connection_Authenticate(username,
password):
raise Exception("Failed to authenticate.")