Version 2.2.1
language :Python
code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from suds.wsse import *
from suds.client import Client
from suds.sax.text import Text
import logging
if __name__ == '__main__':
USER="test"
PASSWD="test"
URL="http://172.31.9.13:8080/cmdbuild/services/soap/Webservices?wsdl"
client = Client(URL)
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
security = Security()
token = UsernameToken('test', 'test')
security.tokens.append(token)
client.set_options(wsse=security)
print client
card = client.service.getCard("test", 25, "", )
Error:
DEBUG:suds.client:sending to (http://172.31.9.13:8080/cmdbuild/services/soap/Webservices)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://soap.services.cmdbuild.org" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>test</wsse:Username>
<wsse:Password>test</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<ns1:Body>
<ns0:getCard>
<ns0:className>test</ns0:className>
<ns0:cardId>25</ns0:cardId>
<ns0:attributeList></ns0:attributeList>
</ns0:getCard>
</ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'""', 'Content-Type': 'text/xml; charset=utf-8'}
ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://soap.services.cmdbuild.org" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>test</wsse:Username>
<wsse:Password>test</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<ns1:Body>
<ns0:getCard>
<ns0:className>test</ns0:className>
<ns0:cardId>25</ns0:cardId>
<ns0:attributeList></ns0:attributeList>
</ns0:getCard>
</ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:http failed:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">ns1:InvalidSecurityToken</faultcode><faultstring>An invalid security token was provided (An error happened processing a Username Token "{0}")</faultstring></soap:Fault></soap:Body></soap:Envelope>
Traceback (most recent call last):
File "test.py", line 26, in <module>
card = client.service.getCard("test", 25, "", )
File "build/bdist.linux-x86_64/egg/suds/client.py", line 542, in __call__
File "build/bdist.linux-x86_64/egg/suds/client.py", line 602, in invoke
File "build/bdist.linux-x86_64/egg/suds/client.py", line 649, in send
File "build/bdist.linux-x86_64/egg/suds/client.py", line 702, in failed
File "build/bdist.linux-x86_64/egg/suds/bindings/binding.py", line 265, in get_fault
suds.WebFault: Server raised fault: 'An invalid security token was provided (An error happened processing a Username Token "{0}")'
Does anyone know why?
Thanks