[Python] Client SOAP

Alberto Abate alberto.abate a gmail.com
Mer 27 Feb 2013 10:43:29 CET


Un saluto a tutti.
sto cercando di accedere ad un webservice tramite un client soap.
Sono assolutamente digiuno del protocollo e facendo delle prove sono
arrivato a questo...
Per verificare le funzionalitą del webservice ho installato soapUI e riesco
a richiamare il metodo "dir" che compone la richesta
soap come riportato in coda...
Ad occhio noto che nella richiesta emessa dal mio script ho:

SOAP-ENV:Envelope
xmlns:ns1
ns1:Body
ns0:dir

mentre in quella di soapUI ho:

soapenv:Envelope
xmlns:web
soapenv:Body
web:dir

avete idea di come risolvere?

Vi seguo con passione anche se scrivo poco,
grazie a tutti ;-))


# INIZIO SCRIPT
*#!/usr/bin/python*
*
*
*from suds.client import Client*
*import logging, sys*
*
*
*class OutgoingFilter(logging.Filter):*
*  def filter(self, record):*
*    return record.msg.startswith('sending:')*
*
*
*
*
*if __name__ == '__main__':*
*
*
*  handler = logging.StreamHandler(sys.stderr)*
*  handler.addFilter(OutgoingFilter())*
*  logger = logging.getLogger('suds.transport.http')*
*  logger.setLevel(logging.DEBUG)*
*  handler.setLevel(logging.DEBUG)*
*  logger.addHandler(handler)*
*
*
*  username = 'username'  # ovviamente ho messo dati validi*
*  password = 'password'*
*  *
*  wsdl_url =
'file:///home/aabate/Documenti/PROGR/webDAA/TelematicoFtp.wsdl'*
*  soap_url = '
https://ws-telematico.agenziadogane.it/TelematicoFtpEjbHttpRouter/TelematicoFtpWsBindingImplService
'*
*
*
*  client = Client(wsdl_url,location=soap_url, username=username,
password=password)*
*  print client*
*
*
*  res = client.service.dir('?')*
*  print res*

# FINE SCRIPT


# INIZIO RISPOSTA
riporto la risposta dello script...

Suds ( https://fedorahosted.org/suds/ )  version: 0.4.1 (beta)  build:
R703-20101015

Service ( TelematicoFtpWsBindingImplService ) tns="
http://webservices.ftp.telematico.dogana.dogane.ag_dogane.finanze.it"
   Prefixes (0)
   Ports (1):
      (TelematicoFtpWsBindingImpl)
         Methods (6):
            dir(xs:string pattern, )
            get(xs:string fileName, )
            getlog()
            ls(xs:string pattern, )
            mget(xs:string mGetInput_Nome, xs:string mGetInput_Prog, )
            put(xs:base64Binary fileMsg_Content, xs:string fileMsg_Nome, )
         Types (0):


sending:
URL:
https://ws-telematico.agenziadogane.it/TelematicoFtpEjbHttpRouter/TelematicoFtpWsBindingImplService
HEADERS: {'SOAPAction': '"dir"', 'Content-Type': 'text/xml; charset=utf-8',
'Content-type': 'text/xml; charset=utf-8', 'Soapaction': '"dir"'}
MESSAGE:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="
http://webservices.ftp.telematico.dogana.dogane.ag_dogane.finanze.it"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
  <ns0:dir><pattern>?</pattern></ns0:dir>
</ns1:Body>
</SOAP-ENV:Envelope>

Traceback (most recent call last):
  File "webdaa.py", line 32, in <module>
    res = client.service.dir('?')
  File "/usr/lib/python2.7/dist-packages/suds/client.py", line 542, in
__call__
    return client.invoke(args, kwargs)
  File "/usr/lib/python2.7/dist-packages/suds/client.py", line 602, in
invoke
    result = self.send(soapenv)
  File "/usr/lib/python2.7/dist-packages/suds/client.py", line 647, in send
    result = self.succeeded(binding, reply.message)
  File "/usr/lib/python2.7/dist-packages/suds/client.py", line 684, in
succeeded
    reply, result = binding.get_reply(self.method, reply)
  File "/usr/lib/python2.7/dist-packages/suds/bindings/binding.py", line
145, in get_reply
    replyroot = sax.parse(string=reply)
  File "/usr/lib/python2.7/dist-packages/suds/sax/parser.py", line 136, in
parse
    sax.parse(source)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 211, in feed
    self._err_handler.fatalError(exc)
  File "/usr/lib/python2.7/xml/sax/handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:0: syntax error


# FINE RISPOSTA

# richiesta methodo "dir" con soapUI

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:web="
http://webservices.ftp.telematico.dogana.dogane.ag_dogane.finanze.it">
   <soapenv:Header/>
   <soapenv:Body>
      <web:dir>
         <pattern>?</pattern>
      </web:dir>
   </soapenv:Body>
</soapenv:Envelope>
-------------- parte successiva --------------
Un allegato HTML č stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20130227/e65b58f8/attachment-0001.html>


Maggiori informazioni sulla lista Python