source: trunk/docs/services/howtos.txt @ 160

Last change on this file since 160 was 146, checked in by jmckenna, 14 years ago

experiment with styling code blocks

File size: 3.3 KB
Line 
1.. _services-howtos:
2
3How To Setup ZOO Services
4=========================
5
6ZOO Services are quiet easy to create once you have install ZOO Kernel and that you have
7chosen a code to turn into a ZOO service. Here are some HelloWorlds in Python, PHP, Java
8and JavaScript with link to the correpondant .zcfg files.
9
10Python
11------
12
13You'll find here informations needed to deploy your own Python Services Provider.
14
15Python ZCFG requirements
16************************
17
18For each Services providen by your ZOO Python Services Provider, the ZCFG File
19have to be named as the Python module function name.
20
21The ZCFG file should contain the following :
22
23
24serviceType
25    Python
26serviceProvider
27    the name of the Python module to use as a ZOO Service Provider. For instance, if your
28    script, located in the same directory as your ZOO Kernel, was named my_module.py then
29    you should use my_module (the Python module name) as serviceProvider value in ZCFG file.
30
31Python Data Structure used
32**************************
33
34The Python module's function to be used as a service have to :
35
36- take three arguments : the main configuration, inputs and outputs maps are passed to the
37  Python module as  dictionaries.
38- return an integer : corresopnding to the service status code.
39
40Sample Data Structure
41*********************
42
43In the following you 'll find a sample argument passed to the Python module's function for
44the two first main configuration file' sections.
45
46::
47
48  main={
49     "main": {"encoding": "utf-8",
50              "version": "1.0.0",
51              "serverAddress": "http://www.zoo-project.org/zoo/",
52              "lang": "fr-FR,en-CA"},
53     "identification": {"title": "The Zoo WPS Development Server",
54                        "abstract": "Development version of ZooWPS.",
55                        "fees": "None",
56                        "accessConstraints": "none",
57                        "keywords": "WPS,GIS,buffer"}
58  }
59
60Sample ZOO Python Services Provider
61***********************************
62
63The following code represent a simple ZOO Python Services Provider which provides only one
64Service, the HelloPy one.
65
66.. code-block:: python
67
68  import sys
69  def HelloPy(conf,inputs,outputs):
70     outputs["Result"]["value"]="Hello "+inputs["a"]["value"]+" from Python World !"
71     return 3
72
73PHP
74---
75
76.. code-block:: php
77
78  <?
79  function HelloPHP(&$main_conf,&$inputs,&$outputs){
80     $outputs["Result"]["value"]="Hello ".$inputs[S][value]." from PHP world !";
81     return 3;
82  }
83  ?>
84
85Java
86----
87
88.. code-block:: java
89
90  import java.util.*;
91  public class HelloJava {
92    public static int HelloWorldJava(HashMap conf,HashMap inputs, HashMap outputs) {
93       HashMap hm1 = new HashMap();
94       hm1.put("dataType","string");
95       HashMap tmp=(HashMap)(inputs.get("S"));
96       java.lang.String v=tmp.get("value").toString();
97       hm1.put("value","Hello "+v+" from JAVA WOrld !");
98       outputs.put("Result",hm1);
99       System.err.println("Hello from JAVA WOrld !");
100       return 3;
101    }
102  }
103
104Javascript
105----------
106
107.. code-block:: javascript
108
109  function hellojs(conf,inputs,outputs){
110     outputs=new Array();
111     outputs[0]={};
112     outputs[0]["result"]["value"]="Hello "+inputs[0]["S"]["value"]+" from JS World !";
113     return Array(3,outputs);
114  }
Note: See TracBrowser for help on using the repository browser.

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png