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

Last change on this file since 315 was 315, checked in by jmckenna, 13 years ago

change header

  • Property svn:keywords set to HeadURL Date Author Id Rev
File size: 3.5 KB
RevLine 
[138]1.. _services-howtos:
2
3How To Setup ZOO Services
[271]4=========================
5
[315]6:Authors: Nicolas Bozon, Gérald Fenoy, Jeff McKenna
7:Last Updated: $Date: 2011-08-11 16:28:42 +0000 (Thu, 11 Aug 2011) $
[138]8
[315]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.
[138]13
[315]14.. contents:: Table of Contents
15    :depth: 3
16    :backlinks: top
17
[138]18Python
19------
20
[315]21You'll find here information needed to deploy your own Python Services Provider.
[138]22
23Python ZCFG requirements
24************************
25
[315]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.
[138]28
29The ZCFG file should contain the following :
30
31
32serviceType
33    Python
34serviceProvider
[315]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.
[138]38
39Python Data Structure used
40**************************
41
[315]42The Python module's function to be used as a service must:
[138]43
44- take three arguments : the main configuration, inputs and outputs maps are passed to the
[315]45  Python module as dictionaries.
46- return an integer : corresponding to the service status code.
[138]47
48Sample Data Structure
49*********************
50
[315]51In the following you'll find a sample argument passed to the Python module's function for
[138]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
[315]71The following code represents a simple ZOO Python Services Provider which provides only one
[138]72Service, the HelloPy one.
73
[146]74.. code-block:: python
[138]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
[146]84.. code-block:: php
[138]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
[146]96.. code-block:: java
[138]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
[146]115.. code-block:: javascript
[138]116
117  function hellojs(conf,inputs,outputs){
118     outputs=new Array();
119     outputs[0]={};
120     outputs[0]["result"]["value"]="Hello "+inputs[0]["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