Page 1 of 1

web service python code

PostPosted:Fri Mar 12, 2010 6:27 pm
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 :)

Re: web service python code

PostPosted:Fri Mar 12, 2010 7:16 pm
by jllort
here are some examples
(4.18 KiB) Downloaded 501 times

Re: web service python code

PostPosted:Sat Mar 13, 2010 3:06 pm
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

Re: web service python code

PostPosted:Sat Mar 13, 2010 4:12 pm
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

Re: web service python code

PostPosted:Mon Mar 15, 2010 11:54 am
by pavila
The second parameter is an document object. See http://wiki.openkm.com/index.php/OKMDocument for the complete API reference.

Re: web service python code

PostPosted:Mon Mar 15, 2010 3:05 pm
by pippo64
Yes we are the italian company interested in OpenKM :)
I will try with your suggestion

Re: web service python code

PostPosted:Tue Mar 16, 2010 5:00 pm
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

Re: web service python code

PostPosted:Thu Mar 18, 2010 9:18 am
by pavila
You have working client sample code at http://wiki.openkm.com/index.php/Python_client.