I have services that are using handle_GET and handle_POST, now I want to call these services from another service with self.invoke(). When I look at the code for client.invoke() it does a self.session.post() call.
Does this mean the I cannot call the handle_GET() of another service using self.invoke() from my service?
one needs to make the target service believe it’s being invoked through an HTTP channel with its WSGI environment so the code will look like below:
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from zato.server.service import Service
class MyService1(Service):
name = 'my.service1'
def handle_GET(self):
self.response.payload = 'Hello'
class MyService2(Service):
name = 'my.service2'
def handle(self):
response = self.invoke('my.service1', wsgi_environ={'REQUEST_METHOD':'GET'})
self.logger.info('Response from handle_GET is `%s`', response)