我想在Python中使用zeep从WSDL中读取数据。这是我的简单代码:
from zeep import Client
client=Client('http://api.netim.com/2.0/api.wsdl')
r = client.service.sessionOpen("username","password",'EN')
x=client.service.domainTldInfo(r,"COM")
print (x)
我收到以下错误:
"No namespace defined for %r (%r)" % (prefix, value))
zeep.exceptions.XMLParseError: No namespace defined for 'tns' ('tns:ArrayOfKeyValueData')
我认为这是WSDL文件中的错误。但是,如果我用php检查相同的操作,则效果很好!
<?php
$clientSOAP = new SoapClient("http://api.netim.com/2.0/api.wsdl");
try
{
$idSession = $clientSOAP->sessionOpen("username", "password", "EN");
$StructDomainTldInfo = $clientSOAP->domainTldInfo($idSession, "COM");
echo "<pre>";
print_r($StructDomainTldInfo);
echo "</pre>";
}
catch(SoapFault $fault)
{
echo "Exception : " .$fault->getMessage(). "\n";
}
if(isset($idSession))
{
$clientSOAP->sessionClose($idSession);
}
?>
感谢您的帮助。