Tuesday, November 28, 2017

Passing parameters to SOAP Zeep client

I'm using Zeep library to query a SOAP webservice wrote in Java.
My piece of the wsdl file is:

<soapenv:Header/>
<soapenv:Body>
  <pag:creaCarrello>
     <GestioneCarrelliRequest>
        <utenteApplicativo>XXXX</utenteApplicativo>
        <carrelloDto>
           <idCarrelloSorgente>11223344</idCarrelloSorgente>
           <itemCarrelloDtoList>
              <causale>prova</causale>
              <codiceEnte>CCIAA_MI</codiceEnte>
              <importo>2</importo>
              <importoImposta>1</importoImposta>
              <importoTotale>3</importoTotale>
              <importoUnitario>2</importoUnitario>
              <quantitaItem>1</quantitaItem>
              <tipoContabilizzazione>TA</tipoContabilizzazione>
           </itemCarrelloDtoList>
        </carrelloDto>
     </GestioneCarrelliRequest>
  </pag:creaCarrello>

and I create a SOAP client in this manner:

def soapclient(request):

     session = Session()
     session.auth = HTTPBasicAuth('user', 'password', transport=Transport(session=session))
     client = Client('my_url_of_wsdl_file.wsdl')

     utenteApplicativo='XXXX'     
     idCarrelloSorgente=11223344
     itemCarrelloDtoList=('prova', 'Datatest', 2, 1, 3, 2, 1, 'TA')
     carrelloDto=(idCarrelloSorgente, itemCarrelloDtoList)
     var=(utenteApplicativo, carrelloDto)
     call=client.service.creaCarrello(var)
     var=(utenteApplicativo, carrelloDto) 

     print('variabile del client: ', var)

     call1=client.service.creaCarrello(var)

     print(call1)
 
but I receive the error: 

ValidationError at /soapclient/
Missing element utenteApplicativo (creaCarrello.GestioneCarrelliRequest)
The problem it seems the manner of passing the parameters. With this other manner:

call=client.service.creaCarrello(XXXX', {11223344, {'causale':'prova', 'codiceEnte':'CCIAA_MI', \
'importo':2, 'importoImposta':1, 'importoTotale':3, 'importoUnitario':2, 'quantitaItem':1, 'tipoContabilizzazione':'TA'}, },)

I receive the error: unhashable type: 'dict'.

Can you help me to understand what is the correct manner to pass these parameters to the zeep client? There are a set of parameters inside another set..Is it supported by zeep?
Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/28b2ad71-3253-442c-8a0e-d1693d117be9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment