Search code examples
pythonweb-servicessoapsoap-clientzeep

ChronoFresh SOAP auth


I'm using the Web Service of Chronopost with the library Zeep.

But I can't authenticate on the method searchDeliverySlot

    wsdl = 'https://ws.chronopost.fr/rdv-cxf/services/CreneauServiceWS?wsdl'
    client = zeep.Client(wsdl=wsdl)

    header = xsd.Element(
        '{http://cxf.soap.ws.creneau.chronopost.fr/}searchDeliverySlot',
        xsd.ComplexType([
            xsd.Element(
                '{http://cxf.soap.ws.creneau.chronopost.fr/}accountNumber',
                xsd.String()),
            xsd.Element(
                '{http://cxf.soap.ws.creneau.chronopost.fr/}password',
                xsd.String()),
        ])
    )
    header_value = header(accountNumber='xxxxxx', password='xxxxx')

    data = client.service.searchDeliverySlot(callerTool='RDVWS',productType='FRESH',shipperZipCode='73000',recipientZipCode='73000',dateBegin=datetime.date(2017, 10, 30),isDeliveryDate=True
        , _soapheaders=[header_value]
        )

I get this error

{
'code': 30,
'message': 'Invalid accesColis password null',
'meshCode': None,
'slotList': [],
'transactionID': None
}

Can you help me to authenticate to the service

thanks


Solution

  • Yes I found the right syntax. To do this I'm help me with SOAP UI which display the right xml object to send

        header = xsd.Element(
            '{http://schemas.xmlsoap.org/soap/envelope/}Header',
            xsd.ComplexType([
                xsd.Element(
                    '{http://cxf.soap.ws.creneau.chronopost.fr/}accountNumber',
                    xsd.String()),
                xsd.Element(
                    '{http://cxf.soap.ws.creneau.chronopost.fr/}password',
                    xsd.String()),
            ])
        )