• web service python code

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #4405  by pippo64
 
Hola
we wrote this small python client , that use susd as soap library, to update a file


import sys
#sys.path.append('../')

import base64
import logging
import traceback as tb
import suds.metrics as metrics
#from tests import *
from suds import WebFault
from suds.client import Client

errors = 0

#setup_logging()

logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.metrics').setLevel(logging.DEBUG)
logging.getLogger('suds').setLevel(logging.DEBUG)


MESSAGGIO="Siamo alla fine del nostro "
testo=open("import.txt", "w")
testo.write(MESSAGGIO)
testo.close()
ciccio = open("import.txt","rb").read().encode("base64")
print ciccio
url = 'http://localhost:8080/OpenKM/OKMDocument?wsdl'
url1 = 'http://localhost:8080/OpenKM/OKMAuth?wsdl'

client = Client(url1)


#sessione=client.service.logout('trippa','trippa')
sessione=client.service.login('utente1','utente1')
print sessione
##
documento = Client(url)
print documento
carica = documento.service.create(sessione,'import.txt',ciccio)
print carica

esci = client.service.logout(sessione)

the 2 files are in the same directory (import.txt and python script), we recive

this errors

Traceback (most recent call last):
File "C:\Documents and Settings\Utente\Desktop\prova_okm.py", line 55, in <module>
carica = documento.service.create(sessione,'import.txt',ciccio)
File "build\bdist.win32\egg\suds\client.py", line 539, in __call__
return client.invoke(args, kwargs)
File "build\bdist.win32\egg\suds\client.py", line 598, in invoke
result = self.send(msg)
File "build\bdist.win32\egg\suds\client.py", line 633, in send
result = self.failed(binding, e)
File "build\bdist.win32\egg\suds\client.py", line 684, in failed
r, p = binding.get_fault(reply)
File "build\bdist.win32\egg\suds\bindings\binding.py", line 238, in get_fault
raise WebFault(p, faultroot)
WebFault: Server raised fault: 'java.lang.NullPointerException'

Please , any idea ?
The others commands goes well delete, cancell, checkout, please help me :)
 #4411  by pippo64
 
Thanks for yours replay
but I already know your scripts, no ones is about create a document on OpenKM, or I'm wrong ;-))
We are very interested in yuor software ad ready to became a partner, if we have to pay
something as support let me known.
Pippo64
 #4412  by jllort
 
Ok, in this case contact with me directly by mail. You're the italian company no ?

About creation, must be a valid openkm path
Code: Select all
'import.txt' it's not a openkm path it must be something like /okm:root/import.txt
 #4421  by pippo64
 
Yes we are the italian company interested in OpenKM :)
I will try with your suggestion
 #4433  by pippo64
 
I got this message from the attached file, any solutions ?
Where is my fault ....? I think is a bug
*** Outgoing SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<ns1:create xmlns:ns1="http://endpoint.ws.openkm.git.es/" SOAP-ENC:root="1">
<arg0 xsi:type="xsd:string">107639652066111454929517431086634</arg0>
<arg1 xsi:type="xsd:string">/okm:root/import.txt</arg1>
<arg2 xsi:type="xsd:string">ZGF0YSB0byBiZSBlbmNvZGVk</arg2>
</ns1:create>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
*** Incoming SOAP ******************************************************
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelop ... <env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelop ... v:Envelope>
************************************************************************
Error in server: (<class 'SOAPpy.Types.faultType'>, <Fault env:Server: java.lang.NullPointerException>, <traceback object at 0x01FF4710>)
Bye

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.