Search code examples
pythonesbpervasivezato

Calling a SOAP service with Python & zato.io


So, I was thinking about trying out the Zato.io ESB with a small project. The flow will be like this:

  1. Expose a simple REST service that will receive one or multiple ids from the clients
  2. Read pkcs12 certificate and call SOAP service once for every id received
  3. Parse huge XML response and post relevant elements to a PervasiveDB

And naturally, handle all possible errors along the way.

As far as I understand, exposing REST will work and I suppose posting to Pervasive will work, but I'm not sure how to handle certificates in zato or python?

Any help appreciated

Regards


Solution

  • Zato 2.0, currently in development and expected to be released soon now, supports SSL/TLS out of the box - you simply upload a custom CA certificate you'd like for a given outgoing connection to use and that's it.

    For Zato 1.1, please find below a working usage example of how to provide paths to CA certificates inline within the body of a service.

    # lxml
    from lxml import etree
    
    # Zato
    from zato.server.service import Service
    
    class MyService(Service):
        def handle(self):
            service = self.outgoing.soap.get('My Connection')
    
            # Invoke a SOAP resource using a custom certificate
            resp = service.conn.send(self.cid, '<data>Here goes payload</data>',
                verify='/path/to/a/certificate')
    
            # Parse resp.text to create an lxml XML object
            xml = etree.fromstring(resp.text)
    

    Cheers!