Answer the question
In order to leave comments, you need to log in
How is authentication done in soap headers, soap client (python + suds)?
Good afternoon, colleagues.
I ran into a problem when writing a soap client.
There is a ready-made version in php:
<?php
1. $client = new SoapClient('https://xx.xx.xx.xx/service/?wsdl');
2. $headers = array();
3. $headers[] = new SoapHeader('http://localhost/auth','Login','admin');
4. $headers[] = new SoapHeader('http://localhost/auth','Password','admin');
5. $client->__setSoapHeaders($headers);
6. $table_hi = $client->getTableByTitle('SomeTable');
7. $row_data = array(
8. array(
9. array(
10. 'name' => 'number',
11. 'value' => '55555555'
12. ),
13. array(
14. 'name' => 'data',
15. 'value' => '20140306185014'
16. ),
17. )
18. );
19. $rowset=$client->insertRowset($table_hi, $row_data);
20. ?>
from suds.client import Client
from suds.xsd.doctor import ImportDoctor, Import
imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
d = ImportDoctor(imp)
client = Client(url='https://xx.xx.xx.xx/service/?wsdl', doctor=d)
client.set_options(soapheaders=['http://localhost/auth','Login','admin'])
client.set_options(soapheaders=['http://localhost/auth','Password','admin'])
result = client.service.getTableByTitle('SomeTable')
Answer the question
In order to leave comments, you need to log in
Perhaps like this:
import suds.client
try:
auth_url = "https://url.to.my.service/authenticator?wsdl"
auth_client = suds.client.Client(auth_url)
cookie = auth_client.service.authenticate(user,password)
except Exception as e:
print str(e)
print auth_client.last_received()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question