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

Last change on this file since 348 was 348, checked in by neteler, 8 years ago

set correctly svn propset

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