Consume webservice, problem with datetime

1

I have this code to consume a webservice

# -*- coding: utf-8 -*-
import zeep
import datetime
from zeep import Client
from zeep.transports import Transport
from zeep import xsd
from zeep.wsse.username import UsernameToken
from requests import Session
from requests.auth import HTTPBasicAuth
from datetime import datetime, timedelta, date
import pytz


url = 'https://facturaelectronica.dian.gov.co/habilitacion/B2BIntegrationEngine/FacturaElectronica/facturaElectronica.wsdl?'
client = Client(wsdl=url )
doc = 'Hello World'.encode()

#obtener fecha y hora actual / convertir en format datetime
formato='%Y-%m-%dT%H:%M:%S.523Z'
tz = pytz.timezone('America/Bogota')
created = datetime.now(tz)
print (created)
print (type(created))


header = zeep.xsd.Element(
        'Security',
        zeep.xsd.ComplexType([
            zeep.xsd.Element(
                'UsernameToken',
                zeep.xsd.ComplexType([
                    zeep.xsd.Element('Username',zeep.xsd.String()),
                    zeep.xsd.Element('Password',zeep.xsd.String()),
                    zeep.xsd.Element('Nonce',zeep.xsd.String()),
                    zeep.xsd.Element('Created',zeep.xsd.String()),

                ])
            ),
        ])
    )

factory = client.type_factory('ns0')
data = factory.EnvioFacturaElectronica()
data.NIT = "901193767"
data.InvoiceNumber = "9011937670"
data.IssueDate = created
data.Document = doc
print (data)
print (data.IssueDate)
print (type(data.IssueDate))

header_value = header(UsernameToken={'Username':'fd0653b3-6dd0-45cd-b2f6-bb108ac83a3a','Password':'6361b7b5322acb07ced00a35a85a4cc5183da3a42ede0b07f578067a18425a55', 'Nonce':'pHgdgwGne5Jw+yHy6SdcyQ==','Created':created})
node = client.service.EnvioFacturaElectronica(
                            _soapheaders=[header_value], *data
                            )

When I run the script I get the following error:

TypeError: combine() argument 1 must be datetime.date, not str

Will someone please execute the script and highlight what is the problem?

    
asked by element 24.08.2018 в 05:19
source

1 answer

0

The same error came to me when I ran your script. Search in google, and it's an "open issue" in "zeep". Here you link (in English) about the "bug" in "zeep"

link

Suggestion: find another package instead of ZEEP. Here are some alternatives: link

Good luck, R6

    
answered by 28.08.2018 в 20:01