Difference between revisions of "Python client - OpenKM 5.1"
From OpenKM Documentation
m (→Perform search) |
(→Authentication) |
||
Line 4: | Line 4: | ||
More info about Python and webservices at http://wiki.python.org/moin/WebServices. | More info about Python and webservices at http://wiki.python.org/moin/WebServices. | ||
+ | |||
+ | == Remote method info == | ||
+ | <source lang="python"> | ||
+ | from SOAPpy import WSDL | ||
+ | |||
+ | # Register WSDL | ||
+ | sAuth = WSDL.Proxy('http://localhost:8080/OpenKM/OKMAuth?wsdl') | ||
+ | |||
+ | print sAuth.methods.keys() | ||
+ | print sAuth.soapproxy | ||
+ | |||
+ | callInfo = sAuth.methods['login'] | ||
+ | |||
+ | print callInfo.inparams[0].name | ||
+ | print callInfo.inparams[0].type | ||
+ | |||
+ | print callInfo.inparams[1].name | ||
+ | print callInfo.inparams[1].type | ||
+ | </source> | ||
== Authentication == | == Authentication == |
Revision as of 18:45, 9 March 2010
These sample code is using the SOAPpy library. If you are in a Debian based distro you can install it this way:
$ sudo aptitude install python-soappy
More info about Python and webservices at http://wiki.python.org/moin/WebServices.
Remote method info
from SOAPpy import WSDL
# Register WSDL
sAuth = WSDL.Proxy('http://localhost:8080/OpenKM/OKMAuth?wsdl')
print sAuth.methods.keys()
print sAuth.soapproxy
callInfo = sAuth.methods['login']
print callInfo.inparams[0].name
print callInfo.inparams[0].type
print callInfo.inparams[1].name
print callInfo.inparams[1].type
Authentication
from SOAPpy import WSDL
# Register WSDL
sAuth = WSDL.Proxy('http://localhost:8080/OpenKM/OKMAuth?wsdl')
# Login
token = sAuth.login(arg0='okmAdmin', arg1='admin')
print 'Token: '+token
# Logout
sAuth.logout(arg0=token)
Perform search
from SOAPpy import WSDL
# Register WSDL
sAuth = WSDL.Proxy('http://localhost:8080/OpenKM/OKMAuth?wsdl')
sSearch = WSDL.Proxy('http://localhost:8080/OpenKM/OKMSearch?wsdl')
# Login
token = sAuth.login(arg0='okmAdmin', arg1='admin')
print 'Token: '+token
# Search
queryResultArray = sSearch.findByContent(arg0=token, arg1='grial')
for queryResult in queryResultArray['value']:
print queryResult['document']['path']
# Logout
sAuth.logout(arg0=token)