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

Last change on this file since 273 was 272, checked in by nbozon, 13 years ago

add keywords with svn propset

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