This how-to shows what is needed to invoke JSON-based web services using Zato, which is a Python-based ESB for SOA, cloud integrations and backend services.


This is the code needed:

400: Invalid request

Read below for the whole story.

SWAPPABLE ENDPOINTS Everything in Zato is about reusability. No information is ever hard-coded hence you don't access any particular addresses directly. Your own services use reusable outgoing connections that are created using the GUI, CLI, API or en masse from config files.

Thus, the code above is simply concerned with producing request and handling response but not with trivialities such as endpoint addresses.

You don't need to code security either - this is added automatically, if needed, by the platform.

For the curious one - HTTP endpoints are based on top of the excellent requests library and you can always access the underlying connection directly if it's needed.


Filling out a form such as below is enough for an outgoing connection to a remote web service be created and propagated across all servers in a Zato cluster.

No restarts are needed. Everything is hot-reconfigured.

Screenshot Screenshot

And that's all there is to it.

Likewise, should you in future need to update an existing definition, this can be done with restarts, by merely filling a form, with no code changes.


Browse the full API and more JSON usage examples here. The tutorial also makes use of JSON in part 2.

And by the way, Zato has support for XML, SOAP, CSV, other data formats, AMQP, FTP, JMS WebSphere MQ, Redis, job scheduling, SQL, ZeroMQ, too!

[Update 2013/08/22] As suggested on Reddit - for SQLAlchemy 0.8+ you should consider using the runtime inspection API instead of accessing low-level details directly.

Being able to convert SQLAlchemy objects into JSON is a useful feature, particularly for the purpose of convenient logging or returning them directly to a JavaScript frontend.

A function to do it can be as simple as the one below (extracted from Zato's source code):

400: Invalid request

The trick is to list all the columns using the model's ._sa_class_manager.mapper.mapped_table.columns attribute and fetch them one by one.

Note that you can also use anyjson which is a useful package that picks the best JSON library available and provides a uniform interface to all of them.

zato-redis-paginator is a library that has been just released and except for the init method, it's 100% API compatible with Django's own pagination but works with Redis instead of SQL databases.

Supported data types:

  • lists
  • sorted sets
  • ranges of sorted sets between min/max scores Consider the code below which uses pagination with a list.

400: Invalid request

Visit the project's home page for more information, including usage examples with other data types and have fun using it!

This how-to shows what is needed to send AMQP messages to exchanges using Zato, which is a Python-based ESB for SOA, cloud integrations and backend services.


This is the code needed:

400: Invalid request

Read below for the whole story.


Before sending a first message, you need to make it known to Zato where messages will be sent as by default Zato encourages separation between services producing messages and the concrete destinations where the messages arrive.

You only invoke a single .send method in your code, without actually specifying particular URLs or credentials, message expiration, content type and so on. You can, but you don't have to.

That all is achieved by means of connection definitions and actual connections. A connection definition is a template describing details of connecting to an AMQP broker - its network address, virtual host, username/password and similar. Each connection definition can be used to create one or more connections that deal with particulars of each message sent - its priority, delivery mode and other per-message information.

Both types of objects are created using Zato's GUI or other means, such as enmasse or API.



First create a connection definition and then use it to create an outgoing connection, as in the screenshots below.

Screenshot Screenshot Screenshot Screenshot

And that concludes it - a new connection has been created and the code shown before can be now hot-deployed in order to send AMQP messages.


Instead, or in addition to, enmasse tool and API can be also used to create, list, update or delete AMQP connections. You're not limited to the GUI only.


Browse the full API and more AMQP usage examples here.

A feature recently added in git development branch that will be released in 2.0 is the ability to specify services to be invoked when a server is starting up.

There's a new stanza in server.conf that lets you assign services and their payload that will be used during a sever's boot, as below.

400: Invalid request
As shown, this can be either a static string or a path to a file containing the data to invoke a service with.