From ca7d1e8ddba5ddb704b039e1bb8a2e289f3a3d6a Mon Sep 17 00:00:00 2001 From: dbs Date: Sat, 25 Oct 2008 17:29:19 +0000 Subject: [PATCH 1/1] Add a basic Python client example git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1479 9efc2488-bf62-4759-914b-345cdb29e865 --- examples/math_client.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/math_client.py diff --git a/examples/math_client.py b/examples/math_client.py new file mode 100644 index 0000000..7dcbdbf --- /dev/null +++ b/examples/math_client.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import osrf.system +import osrf.ses + +# XXX: Replace with command line arguments +file = '/opensrf/conf/opensrf_core.xml' +operator = 'add' +operand1 = 5 +operand2 = 7 + +# Pull connection settings from section of opensrf_core.xml +osrf.system.System.connect(config_file=file, config_context='config.opensrf') + +# Set up a connection to the opensrf.math service +session = osrf.ses.ClientSession('opensrf.math') + +# Call one of the methods defined by the opensrf.math service +request = session.request(operator, operand1, operand2) + +# Retrieve the response from the method +response = request.recv(timeout=2) + +print(response.content()) + +# Cleanup request and connection resources +request.cleanup() +session.cleanup() -- 2.43.2