]> git.evergreen-ils.org Git - OpenSRF.git/blob - examples/math_client.py.in
more test
[OpenSRF.git] / examples / math_client.py.in
1 #!/usr/bin/env python
2 import osrf.system
3 import osrf.ses
4
5 # XXX: Replace with command line arguments
6 file = '@sysconfdir@/opensrf_core.xml'
7 operator = 'add'
8 operand1 = 5
9 operand2 = 7
10
11 # Pull connection settings from <config><opensrf> section of opensrf_core.xml
12 osrf.system.System.connect(config_file=file, config_context='config.opensrf')
13
14 # Set up a connection to the opensrf.math service
15 session = osrf.ses.ClientSession('opensrf.math')
16
17 # Call one of the methods defined by the opensrf.math service
18 request = session.request(operator, operand1, operand2)
19
20 # Retrieve the response from the method
21 response = request.recv(timeout=2)
22
23 print(response.content())
24
25 # Cleanup request and connection resources
26 request.cleanup()
27 session.cleanup()