Hi all,
I developed a soap server using python ZSI. The server is running fine but the problem appears when I'm trying to log the xml received into a file:
import logging as log
LOG_FILENAME = '/var/log/zsiserver.log'
log.basicConfig(filename=LOG_FILENAME,level=log.DEBUG,)
from ZSI import dispatch
from mod_python import apache
mod = __import__('encodings.utf_8', globals(), locals(), '*')
mod = __import__('encodings.utf_16_be', globals(), locals(), '*')
import MyHandler
def handler(req):
# log.debug('data received: ' + req.the_request)
log.debug('data received: ' + req.read())
dispatch.AsHandler(modules=(MyHandler,), request=req)
return apache.OK
The log created is:
data received: <SOAP-ENV:Envelope xmlns:ns0="http://www.csapi.org/schema/parlayx/sms/notification/v2_2/local" 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:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>myusername</wsse:Username>
<wsse:Password>mypassword</wsse:Password>
<wsse:Nonce>811d071cec4569317ec4ae9c627cc592</wsse:Nonce>
<wsu:Created>2010-10-19T11:12:30.268105</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns0:notifySmsReception>
<ns0:correlator>666</ns0:correlator>
<ns0:message>yihaaaaaaaaaa</ns0:message>
</ns0:notifySmsReception>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I think the problem is with the req.read() because it close the stream and makes a crash into dispatch.AsHandler function. If I delete the req.read() instruction, the server runs fine. How I can do to log the xml received?
Another question, it's possible with the ZSI library to parse a digest header to validate the username and password?
Thanks in advance for your help.