ZooWebSite/ZooServices/Examples

Version 3 (modified by djay, 15 years ago)

--

ZOO Services HowTos

ZOO Services are quiet easy to create once you have install ZOO Kernel and that you have chosen a code to turn into a ZOO service. Here are some HelloWorlds in Python, PHP, Java and JavaScript with link to the correpondant .zcfg files.

Python

You'll find here informations needed to deploy your own Python Services Provider.

Python ZCFG requirements

For each Services providen by your ZOO Python Services Provider, the ZCFG File have to be named as the Python module function name.

The ZCFG file should contain the following :

serviceType
Python
serviceProvider
the name of the Python module to use as a ZOO Service Provider. For instance, if your script, located in the same directory as your ZOO Kernel, was named my_module.py then you should use my_module (the Python module name) as serviceProvider value in ZCFG file.

Python Data Structure used

The Python module's function to be used as a service have to :

  • take three arguments : the main configuration, inputs and outputs maps are passed to the Python module as dictionaries.
  • return an integer : corresopnding to the service status code.

Sample Data Structure

In the following you 'll find a sample argument passed to the Python module's function for the two first main configuration file' sections.

main={
   "main": {"encoding": "utf-8",
            "version": "1.0.0",
            "serverAddress": "http://www.zoo-project.org/zoo/",
            "lang": "fr-FR,en-CA"}, 
   "identification": {"title": "The Zoo WPS Development Server",
                      "abstract": "Development version of ZooWPS.",
                      "fees": "None",
                      "accessConstraints": "none",
                      "keywords": "WPS,GIS,buffer"}
}

Sample ZOO Python Services Provider

The following code represent a simple ZOO Python Services Provider which provides only one Service, the HelloPy one.

import sys
def HelloPy(conf,inputs,outputs):
   outputs["Result"]["value"]="Hello "+inputs["a"]["value"]+" from Python World !"
   return 3
The ZCFG File DescribeProcessRawDataOutput

PHP

<?
function HelloPHP(&$main_conf,&$inputs,&$outputs){
   $outputs["Result"]["value"]="Hello ".$inputs[S][value]." from PHP world !";
   return 3;
}
?>

Link to HelloPHP.zcfg

Java

import java.util.*;
public class HelloJava {
  public static int HelloWorldJava(HashMap conf,HashMap inputs, HashMap outputs) {
     HashMap hm1 = new HashMap();
     hm1.put("dataType","string");
     HashMap tmp=(HashMap)(inputs.get("S"));
     java.lang.String v=tmp.get("value").toString();
     hm1.put("value","Hello "+v+" from JAVA WOrld !");
     outputs.put("Result",hm1);
     System.err.println("Hello from JAVA WOrld !");
     return 3;
  }
}

Link to HelloJava.zcfg

Javascript

function hellojs(conf,inputs,outputs){
   outputs=new Array();
   outputs[0]={};
   outputs[0]["result"]["value"]="Hello "+inputs[0]["S"]["value"]+" from JS World !";
   return Array(3,outputs);
}

Link to Hellojs.zcfg

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