1 | |
---|
2 | |
---|
3 | <!DOCTYPE html> |
---|
4 | <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> |
---|
5 | <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> |
---|
6 | <head> |
---|
7 | <meta charset="utf-8"> |
---|
8 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
---|
9 | |
---|
10 | <title>Create your own ZOO-Services — ZOO-Project 1.4a0 documentation</title> |
---|
11 | |
---|
12 | <link href="http://fonts.googleapis.com/css?family=Days+One" rel="stylesheet" type="text/css"> |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | <link rel="search" type="application/opensearchdescription+xml" title="Search within ZOO-Project 1.4a0 documentation" href="../_static/opensearch.xml"/> |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | <link rel="top" title="ZOO-Project 1.4a0 documentation" href="../index.html"/> |
---|
35 | <link rel="up" title="ZOO-Services" href="index.html"/> |
---|
36 | <link rel="next" title="ZOO Status Service" href="status.html"/> |
---|
37 | <link rel="prev" title="Process profiles registry" href="process-profiles.html"/> |
---|
38 | |
---|
39 | |
---|
40 | <script src="_static/js/modernizr.min.js"></script> |
---|
41 | |
---|
42 | </head> |
---|
43 | |
---|
44 | <body class="wy-body-for-nav" role="document"> |
---|
45 | |
---|
46 | <div class="wy-grid-for-nav"> |
---|
47 | |
---|
48 | |
---|
49 | <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
---|
50 | <div class="wy-side-nav-search"> |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | <a class="shrink" href="http://zoo-project.org"><img src="http://zoo-project.org/img/zoo-sun-logo.png" class="img-responsive sun" style="display: inline;"> ZOO</a> |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | </a> |
---|
59 | |
---|
60 | |
---|
61 | <div role="search"> |
---|
62 | <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
---|
63 | <input type="text" name="q" placeholder="Search docs" /> |
---|
64 | <input type="hidden" name="check_keywords" value="yes" /> |
---|
65 | <input type="hidden" name="area" value="default" /> |
---|
66 | </form> |
---|
67 | </div> |
---|
68 | |
---|
69 | |
---|
70 | </div> |
---|
71 | |
---|
72 | <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | <ul class="current"> |
---|
77 | <li class="toctree-l1"><a class="reference internal" href="../intro.html">Introduction</a><ul> |
---|
78 | <li class="toctree-l2"><a class="reference internal" href="../intro.html#what-is-zoo-project">What is ZOO-Project ?</a></li> |
---|
79 | <li class="toctree-l2"><a class="reference internal" href="../intro.html#zoo-project-components">ZOO-Project components</a></li> |
---|
80 | <li class="toctree-l2"><a class="reference internal" href="../intro.html#open-source">Open Source</a></li> |
---|
81 | </ul> |
---|
82 | </li> |
---|
83 | <li class="toctree-l1"><a class="reference internal" href="../install/index.html">ZOO-Project installation</a><ul> |
---|
84 | <li class="toctree-l2"><a class="reference internal" href="../install/install-prerequisites.html">Prerequisites</a></li> |
---|
85 | <li class="toctree-l2"><a class="reference internal" href="../install/install-download.html">Download</a></li> |
---|
86 | <li class="toctree-l2"><a class="reference internal" href="../install/install-confoptions.html">Configure options</a></li> |
---|
87 | <li class="toctree-l2"><a class="reference internal" href="../install/install-installation.html">Installation on Unix/Linux</a></li> |
---|
88 | <li class="toctree-l2"><a class="reference internal" href="../install/install-onwindows.html">Installation on Windows ™</a></li> |
---|
89 | <li class="toctree-l2"><a class="reference internal" href="../install/install-onmacos.html">Installation on MacOSX ™</a></li> |
---|
90 | </ul> |
---|
91 | </li> |
---|
92 | <li class="toctree-l1"><a class="reference internal" href="../kernel/index.html">ZOO-Kernel</a><ul> |
---|
93 | <li class="toctree-l2"><a class="reference internal" href="../kernel/what.html">What is ZOO-Kernel ?</a></li> |
---|
94 | <li class="toctree-l2"><a class="reference internal" href="../kernel/configuration.html">ZOO-Kernel configuration</a></li> |
---|
95 | <li class="toctree-l2"><a class="reference internal" href="../kernel/mapserver.html">Optional MapServer support</a></li> |
---|
96 | <li class="toctree-l2"><a class="reference internal" href="../kernel/orfeotoolbox.html">Optional Orfeo Toolbox support</a></li> |
---|
97 | <li class="toctree-l2"><a class="reference internal" href="../kernel/sagagis.html">Optional SAGA GIS support</a></li> |
---|
98 | </ul> |
---|
99 | </li> |
---|
100 | <li class="toctree-l1 current"><a class="reference internal" href="index.html">ZOO-Services</a><ul class="current"> |
---|
101 | <li class="toctree-l2"><a class="reference internal" href="what.html">What are ZOO-Services ?</a></li> |
---|
102 | <li class="toctree-l2"><a class="reference internal" href="zcfg-reference.html">ZOO-Service configuration file</a></li> |
---|
103 | <li class="toctree-l2"><a class="reference internal" href="process-profiles.html">Process profiles registry</a></li> |
---|
104 | <li class="toctree-l2 current"><a class="current reference internal" href="">Create your own ZOO-Services</a></li> |
---|
105 | <li class="toctree-l2"><a class="reference internal" href="status.html">ZOO Status Service</a></li> |
---|
106 | <li class="toctree-l2"><a class="reference internal" href="debug.html">Debugging ZOO Services</a></li> |
---|
107 | <li class="toctree-l2"><a class="reference internal" href="zoo-services.html">Available ZOO-Services</a></li> |
---|
108 | </ul> |
---|
109 | </li> |
---|
110 | <li class="toctree-l1"><a class="reference internal" href="../api/index.html">ZOO-API</a><ul> |
---|
111 | <li class="toctree-l2"><a class="reference internal" href="../api/what.html">What is ZOO-API ?</a></li> |
---|
112 | <li class="toctree-l2"><a class="reference internal" href="../api/howto.html">Using ZOO-API</a></li> |
---|
113 | <li class="toctree-l2"><a class="reference internal" href="../api/classes.html">ZOO-API Classes</a></li> |
---|
114 | <li class="toctree-l2"><a class="reference internal" href="../api/examples.html">Examples</a></li> |
---|
115 | </ul> |
---|
116 | </li> |
---|
117 | <li class="toctree-l1"><a class="reference internal" href="../client/index.html">ZOO-Client</a><ul> |
---|
118 | <li class="toctree-l2"><a class="reference internal" href="../client/what.html">What is ZOO-Client ?</a></li> |
---|
119 | <li class="toctree-l2"><a class="reference internal" href="../client/howto.html">Using ZOO-Client</a></li> |
---|
120 | <li class="toctree-l2"><a class="reference internal" href="../client/example.html">Example application</a></li> |
---|
121 | </ul> |
---|
122 | </li> |
---|
123 | <li class="toctree-l1"><a class="reference internal" href="../contribute/index.html">Contributor Guide</a><ul> |
---|
124 | <li class="toctree-l2"><a class="reference internal" href="../contribute/howto.html">How to contribute ?</a></li> |
---|
125 | <li class="toctree-l2"><a class="reference internal" href="../contribute/code.html">Contribute code</a></li> |
---|
126 | </ul> |
---|
127 | </li> |
---|
128 | </ul> |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | </div> |
---|
133 | |
---|
134 | </nav> |
---|
135 | |
---|
136 | <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
---|
137 | |
---|
138 | |
---|
139 | <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> |
---|
140 | <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
---|
141 | <a href="../contents.html">ZOO-Project</a> |
---|
142 | </nav> |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | <div class="wy-nav-content"> |
---|
147 | <div class="rst-content"> |
---|
148 | <div role="navigation" aria-label="breadcrumbs navigation"> |
---|
149 | <ul class="wy-breadcrumbs"> |
---|
150 | |
---|
151 | <li><a href="../contents.html"> Docs</a> ∕  </li> |
---|
152 | |
---|
153 | <li><a href="index.html">ZOO-Services</a> ∕  </li> |
---|
154 | |
---|
155 | <li>Create your own ZOO-Services</li> |
---|
156 | <li class="wy-breadcrumbs-aside"> |
---|
157 | |
---|
158 | <a href="../_sources/services/howtos.txt" rel="nofollow"> View page source</a> |
---|
159 | |
---|
160 | </li> |
---|
161 | </ul> |
---|
162 | <hr/> |
---|
163 | </div> |
---|
164 | <div role="main" class="document"> |
---|
165 | |
---|
166 | <div class="section" id="create-your-own-zoo-services"> |
---|
167 | <span id="services-create"></span><h1>Create your own ZOO-Services<a class="headerlink" href="#create-your-own-zoo-services" title="Permalink to this headline">¶</a></h1> |
---|
168 | <p><a class="reference internal" href="index.html#services-index"><span>ZOO-Services</span></a> are quite easy to create once you have installed the ZOO Kernel and have |
---|
169 | chosen code (in the language of your choice) to turn into a ZOO service. Here are some |
---|
170 | HelloWorlds in Python, PHP, Java and JavaScript with links to their corresponding |
---|
171 | <code class="docutils literal"><span class="pre">.zcfg</span></code> files.</p> |
---|
172 | <div class="section" id="general-information"> |
---|
173 | <h2>General information<a class="headerlink" href="#general-information" title="Permalink to this headline">¶</a></h2> |
---|
174 | <p>The function of the process for each programming language take three arguments: the main |
---|
175 | configuration, inputs and outputs.</p> |
---|
176 | <div class="admonition note"> |
---|
177 | <p class="first admonition-title">Note</p> |
---|
178 | <p class="last">The service must return <strong>3</strong> if the process run successfully</p> |
---|
179 | </div> |
---|
180 | <div class="admonition note"> |
---|
181 | <p class="first admonition-title">Note</p> |
---|
182 | <p class="last">The service must return <strong>4</strong> if the process ended with an error</p> |
---|
183 | </div> |
---|
184 | </div> |
---|
185 | <div class="section" id="python"> |
---|
186 | <h2>Python<a class="headerlink" href="#python" title="Permalink to this headline">¶</a></h2> |
---|
187 | <p>You’ll find here information needed to deploy your own Python Services Provider.</p> |
---|
188 | <div class="section" id="python-zcfg-requirements"> |
---|
189 | <h3>Python ZCFG requirements<a class="headerlink" href="#python-zcfg-requirements" title="Permalink to this headline">¶</a></h3> |
---|
190 | <div class="admonition note"> |
---|
191 | <p class="first admonition-title">Note</p> |
---|
192 | <p class="last">For each Service provided by your ZOO Python Services Provider, the ZCFG File |
---|
193 | must be named the same as the Python module function name (also the case of |
---|
194 | characters is important).</p> |
---|
195 | </div> |
---|
196 | <p>The ZCFG file should contain the following :</p> |
---|
197 | <dl class="docutils"> |
---|
198 | <dt>serviceType</dt> |
---|
199 | <dd>Python</dd> |
---|
200 | <dt>serviceProvider</dt> |
---|
201 | <dd>The name of the Python module to use as a ZOO Service Provider. For instance, if your |
---|
202 | script, located in the same directory as your ZOO Kernel, was named <code class="docutils literal"><span class="pre">my_module.py</span></code> then |
---|
203 | you should use <code class="docutils literal"><span class="pre">my_module</span></code> (the Python module name) for the serviceProvider value in ZCFG file.</dd> |
---|
204 | </dl> |
---|
205 | </div> |
---|
206 | <div class="section" id="python-data-structure-used"> |
---|
207 | <h3>Python Data Structure used<a class="headerlink" href="#python-data-structure-used" title="Permalink to this headline">¶</a></h3> |
---|
208 | <p>The three parameters of the function are passed to the Python module as dictionaries.</p> |
---|
209 | <p>Following you’ll find an example for each parameters</p> |
---|
210 | <div class="section" id="main-configuration"> |
---|
211 | <h4>Main configuration<a class="headerlink" href="#main-configuration" title="Permalink to this headline">¶</a></h4> |
---|
212 | <p>Main configuration contains several informations, some of them are really useful to develop your service. |
---|
213 | Following an example</p> |
---|
214 | <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
---|
215 | <span class="s">'main'</span><span class="p">:</span> <span class="p">{</span><span class="s">'lang'</span><span class="p">:</span> <span class="s">'en-UK'</span><span class="p">,</span> |
---|
216 | <span class="s">'language'</span><span class="p">:</span> <span class="s">'en-US'</span><span class="p">,</span> |
---|
217 | <span class="s">'encoding'</span><span class="p">:</span> <span class="s">'utf-8'</span><span class="p">,</span> |
---|
218 | <span class="s">'dataPath'</span><span class="p">:</span> <span class="s">'/var/www/tmp'</span><span class="p">,</span> |
---|
219 | <span class="s">'tmpPath'</span><span class="p">:</span> <span class="s">'/var/www/tmp'</span><span class="p">,</span> |
---|
220 | <span class="s">'version'</span><span class="p">:</span> <span class="s">'1.0.0'</span><span class="p">,</span> |
---|
221 | <span class="s">'mapserverAddress'</span><span class="p">:</span> <span class="s">'http://localhost/cgi-bin/mapserv'</span><span class="p">,</span> |
---|
222 | <span class="s">'isSoap'</span><span class="p">:</span> <span class="s">'false'</span><span class="p">,</span> |
---|
223 | <span class="s">'tmpUrl'</span><span class="p">:</span> <span class="s">'http://localhost/tmp/'</span><span class="p">,</span> |
---|
224 | <span class="s">'serverAddress'</span><span class="p">:</span> <span class="s">'http://localhost/zoo'</span> |
---|
225 | <span class="p">},</span> |
---|
226 | <span class="s">'identification'</span><span class="p">:</span> <span class="p">{</span><span class="s">'keywords'</span><span class="p">:</span> <span class="s">'WPS,GIS'</span><span class="p">,</span> |
---|
227 | <span class="s">'abstract'</span><span class="p">:</span> <span class="s">'WPS services for testing ZOO'</span><span class="p">,</span> |
---|
228 | <span class="s">'fees'</span><span class="p">:</span> <span class="s">'None'</span><span class="p">,</span> |
---|
229 | <span class="s">'accessConstraints'</span><span class="p">:</span> <span class="s">'none'</span><span class="p">,</span> |
---|
230 | <span class="s">'title'</span><span class="p">:</span> <span class="s">'testing services'</span> |
---|
231 | <span class="p">},</span> |
---|
232 | <span class="s">'lenv'</span><span class="p">:</span> <span class="p">{</span><span class="s">'status'</span><span class="p">:</span> <span class="s">'0'</span><span class="p">,</span> |
---|
233 | <span class="s">'soap'</span><span class="p">:</span> <span class="s">'false'</span><span class="p">,</span> |
---|
234 | <span class="s">'cwd'</span><span class="p">:</span> <span class="s">'/usr/lib/cgi-bin'</span><span class="p">,</span> |
---|
235 | <span class="s">'sid'</span><span class="p">:</span> <span class="s">'24709'</span> |
---|
236 | <span class="p">},</span> |
---|
237 | <span class="s">'env'</span><span class="p">:</span> <span class="p">{</span><span class="s">'DISPLAY'</span><span class="p">:</span> <span class="s">'localhost:0'</span><span class="p">},</span> |
---|
238 | <span class="s">'provider'</span><span class="p">:</span> <span class="p">{</span><span class="s">'addressCountry'</span><span class="p">:</span> <span class="s">'it'</span><span class="p">,</span> |
---|
239 | <span class="s">'positionName'</span><span class="p">:</span> <span class="s">'Developer'</span><span class="p">,</span> |
---|
240 | <span class="s">'providerName'</span><span class="p">:</span> <span class="s">'Name of provider'</span><span class="p">,</span> |
---|
241 | <span class="s">'addressAdministrativeArea'</span><span class="p">:</span> <span class="s">'False'</span><span class="p">,</span> |
---|
242 | <span class="s">'phoneVoice'</span><span class="p">:</span> <span class="s">'False'</span><span class="p">,</span> |
---|
243 | <span class="s">'addressCity'</span><span class="p">:</span> <span class="s">'City'</span><span class="p">,</span> |
---|
244 | <span class="s">'providerSite'</span><span class="p">:</span> <span class="s">'http://www.your.site'</span><span class="p">,</span> |
---|
245 | <span class="s">'addressPostalCode'</span><span class="p">:</span> <span class="s">'38122'</span><span class="p">,</span> |
---|
246 | <span class="s">'role'</span><span class="p">:</span> <span class="s">'Developer'</span><span class="p">,</span> |
---|
247 | <span class="s">'addressDeliveryPoint'</span><span class="p">:</span> <span class="s">'False'</span><span class="p">,</span> |
---|
248 | <span class="s">'phoneFacsimile'</span><span class="p">:</span> <span class="s">'False'</span><span class="p">,</span> |
---|
249 | <span class="s">'addressElectronicMailAddress'</span><span class="p">:</span> <span class="s">'your@email.com'</span><span class="p">,</span> |
---|
250 | <span class="s">'individualName'</span><span class="p">:</span> <span class="s">'Your Name'</span> |
---|
251 | <span class="p">}</span> |
---|
252 | <span class="p">}</span> |
---|
253 | </pre></div> |
---|
254 | </div> |
---|
255 | </div> |
---|
256 | <div class="section" id="inputs"> |
---|
257 | <h4>Inputs<a class="headerlink" href="#inputs" title="Permalink to this headline">¶</a></h4> |
---|
258 | <p>The inputs are somethings like this</p> |
---|
259 | <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
---|
260 | <span class="s">'variable_name'</span><span class="p">:</span> <span class="p">{</span><span class="s">'minOccurs'</span><span class="p">:</span> <span class="s">'1'</span><span class="p">,</span> |
---|
261 | <span class="s">'DataType'</span><span class="p">:</span> <span class="s">'string'</span><span class="p">,</span> |
---|
262 | <span class="s">'value'</span><span class="p">:</span> <span class="s">'this_is_the_value'</span><span class="p">,</span> |
---|
263 | <span class="s">'maxOccurs'</span><span class="p">:</span> <span class="s">'1'</span><span class="p">,</span> |
---|
264 | <span class="s">'inRequest'</span><span class="p">:</span> <span class="s">'true'</span> |
---|
265 | <span class="p">}</span> |
---|
266 | <span class="p">}</span> |
---|
267 | </pre></div> |
---|
268 | </div> |
---|
269 | <p>The access to the value you have to require for the <code class="docutils literal"><span class="pre">value</span></code> parameter, something like this</p> |
---|
270 | <div class="highlight-python"><div class="highlight"><pre><span class="n">yourVariable</span> <span class="o">=</span> <span class="n">inputs</span><span class="p">[</span><span class="s">'variable_name'</span><span class="p">][</span><span class="s">'value'</span><span class="p">]</span> |
---|
271 | </pre></div> |
---|
272 | </div> |
---|
273 | </div> |
---|
274 | <div class="section" id="outputs"> |
---|
275 | <h4>Outputs<a class="headerlink" href="#outputs" title="Permalink to this headline">¶</a></h4> |
---|
276 | <p>The outputs data as a structure really similar to the inputs one</p> |
---|
277 | <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
---|
278 | <span class="s">'result'</span><span class="p">:</span> <span class="p">{</span><span class="s">'DataType'</span><span class="p">:</span> <span class="s">'string'</span><span class="p">,</span> |
---|
279 | <span class="s">'inRequest'</span><span class="p">:</span> <span class="s">'true'</span><span class="p">,</span> |
---|
280 | <span class="p">}</span> |
---|
281 | <span class="p">}</span> |
---|
282 | </pre></div> |
---|
283 | </div> |
---|
284 | <p>There is no <code class="docutils literal"><span class="pre">'value'</span></code> parameter before you assign it</p> |
---|
285 | <div class="highlight-python"><div class="highlight"><pre><span class="n">inputs</span><span class="p">[</span><span class="s">'result'</span><span class="p">][</span><span class="s">'value'</span><span class="p">]</span> <span class="o">=</span> <span class="n">yourOutputDataVariable</span> |
---|
286 | </pre></div> |
---|
287 | </div> |
---|
288 | <p>The return statement has to be an integer: corresponding to the service status code.</p> |
---|
289 | <p>To add a message for the wrong result you can add the massage to <code class="docutils literal"><span class="pre">conf["lenv"]["message"]</span></code>, |
---|
290 | for example:</p> |
---|
291 | <div class="highlight-python"><div class="highlight"><pre><span class="n">conf</span><span class="p">[</span><span class="s">"lenv"</span><span class="p">][</span><span class="s">"message"</span><span class="p">]</span> <span class="o">=</span> <span class="s">'Your module return an error'</span> |
---|
292 | </pre></div> |
---|
293 | </div> |
---|
294 | </div> |
---|
295 | </div> |
---|
296 | <div class="section" id="sample-zoo-python-services-provider"> |
---|
297 | <h3>Sample ZOO Python Services Provider<a class="headerlink" href="#sample-zoo-python-services-provider" title="Permalink to this headline">¶</a></h3> |
---|
298 | <p>The following code represents a simple ZOO Python Services Provider which provides only one |
---|
299 | Service, the HelloPy one.</p> |
---|
300 | <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">zoo</span> |
---|
301 | <span class="kn">import</span> <span class="nn">sys</span> |
---|
302 | <span class="k">def</span> <span class="nf">HelloPy</span><span class="p">(</span><span class="n">conf</span><span class="p">,</span><span class="n">inputs</span><span class="p">,</span><span class="n">outputs</span><span class="p">):</span> |
---|
303 | <span class="n">outputs</span><span class="p">[</span><span class="s">"Result"</span><span class="p">][</span><span class="s">"value"</span><span class="p">]</span><span class="o">=</span><span class="s">"Hello "</span><span class="o">+</span><span class="n">inputs</span><span class="p">[</span><span class="s">"a"</span><span class="p">][</span><span class="s">"value"</span><span class="p">]</span><span class="o">+</span><span class="s">" from Python World !"</span> |
---|
304 | <span class="k">return</span> <span class="n">zoo</span><span class="o">.</span><span class="n">SERVICE_SUCCEEDED</span> |
---|
305 | </pre></div> |
---|
306 | </div> |
---|
307 | </div> |
---|
308 | </div> |
---|
309 | <div class="section" id="php"> |
---|
310 | <h2>PHP<a class="headerlink" href="#php" title="Permalink to this headline">¶</a></h2> |
---|
311 | <div class="section" id="zoo-api"> |
---|
312 | <h3>ZOO-API<a class="headerlink" href="#zoo-api" title="Permalink to this headline">¶</a></h3> |
---|
313 | <p>The ZOO-API for the PHP language is automatically available from your |
---|
314 | service code. Tthe following functions are defined in the ZOO-API:</p> |
---|
315 | <dl class="docutils"> |
---|
316 | <dt>int zoo_SERVICE_SUCCEEDED()</dt> |
---|
317 | <dd>return the value of SERVICE_SUCCEEDED</dd> |
---|
318 | <dt>int zoo_SERVICE_FAILED()</dt> |
---|
319 | <dd>return the value of SERVICE_FAILED</dd> |
---|
320 | <dt>string zoo_Translate(string a)</dt> |
---|
321 | <dd>return the translated string (using the “zoo-service” <a class="reference external" href="http://www.gnu.org/software/libc/manual/html_node/Locating-gettext-catalog.html#index-textdomain">textdomain</a>)</dd> |
---|
322 | <dt>void zoo_UpdateStatus(Array conf,string message,int pourcent)</dt> |
---|
323 | <dd>update the status of the running service</dd> |
---|
324 | </dl> |
---|
325 | </div> |
---|
326 | <div class="section" id="php-zcfg-requirements"> |
---|
327 | <h3>PHP ZCFG requirements<a class="headerlink" href="#php-zcfg-requirements" title="Permalink to this headline">¶</a></h3> |
---|
328 | <p>The ZCFG file should contain the following :</p> |
---|
329 | <dl class="docutils"> |
---|
330 | <dt>serviceType</dt> |
---|
331 | <dd>PHP</dd> |
---|
332 | <dt>serviceProvider</dt> |
---|
333 | <dd>The name of the php script (ie. service.php) to use as a ZOO Service Provider.</dd> |
---|
334 | </dl> |
---|
335 | </div> |
---|
336 | <div class="section" id="php-data-structure-used"> |
---|
337 | <h3>PHP Data Structure used<a class="headerlink" href="#php-data-structure-used" title="Permalink to this headline">¶</a></h3> |
---|
338 | <p>The three parameters are passed to the PHP function as |
---|
339 | <a class="reference external" href="php.net/manual/language.types.array.php">Arrays</a>.</p> |
---|
340 | </div> |
---|
341 | <div class="section" id="sample-zoo-php-services-provider"> |
---|
342 | <h3>Sample ZOO PHP Services Provider<a class="headerlink" href="#sample-zoo-php-services-provider" title="Permalink to this headline">¶</a></h3> |
---|
343 | <div class="highlight-php"><div class="highlight"><pre><span class="cp"><?</span> |
---|
344 | <span class="k">function</span> <span class="nf">HelloPHP</span><span class="p">(</span><span class="o">&</span><span class="nv">$main_conf</span><span class="p">,</span><span class="o">&</span><span class="nv">$inputs</span><span class="p">,</span><span class="o">&</span><span class="nv">$outputs</span><span class="p">){</span> |
---|
345 | <span class="nv">$tmp</span><span class="o">=</span><span class="s2">"Hello "</span><span class="o">.</span><span class="nv">$inputs</span><span class="p">[</span><span class="nx">S</span><span class="p">][</span><span class="nx">value</span><span class="p">]</span><span class="o">.</span><span class="s2">" from PHP world !"</span><span class="p">;</span> |
---|
346 | <span class="nv">$outputs</span><span class="p">[</span><span class="s2">"Result"</span><span class="p">][</span><span class="s2">"value"</span><span class="p">]</span><span class="o">=</span><span class="nx">zoo_Translate</span><span class="p">(</span><span class="nv">$tmp</span><span class="p">);</span> |
---|
347 | <span class="k">return</span> <span class="nx">zoo_SERVICE_SUCCEEDED</span><span class="p">();</span> |
---|
348 | <span class="p">}</span> |
---|
349 | <span class="cp">?></span><span class="x"></span> |
---|
350 | </pre></div> |
---|
351 | </div> |
---|
352 | </div> |
---|
353 | </div> |
---|
354 | <div class="section" id="java"> |
---|
355 | <h2>Java<a class="headerlink" href="#java" title="Permalink to this headline">¶</a></h2> |
---|
356 | <p>Specifically for the Java support, you may add the following two |
---|
357 | sections to your <code class="docutils literal"><span class="pre">main.cfg</span></code> file:</p> |
---|
358 | <table class="docutils field-list" frame="void" rules="none"> |
---|
359 | <col class="field-name" /> |
---|
360 | <col class="field-body" /> |
---|
361 | <tbody valign="top"> |
---|
362 | <tr class="field-odd field"><th class="field-name">[javaxx]:</th><td class="field-body">This section is used to pass -XX:* parameters to the JVM created by the |
---|
363 | ZOO-Kernel to handle your ZOO-Service (see <a class="reference external" href="http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html#BehavioralOptions">ref. 1</a> |
---|
364 | or <a class="reference external" href="http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html#PerformanceTuning">ref. 2</a> |
---|
365 | for sample available). |
---|
366 | For each map <code class="docutils literal"><span class="pre">a</span> <span class="pre">=</span> <span class="pre">b</span></code> available in the <code class="docutils literal"><span class="pre">[javaxx]</span></code> section, the |
---|
367 | option <code class="docutils literal"><span class="pre">-XX:a=b</span></code> will be passed to the JVM. In case of a map <code class="docutils literal"><span class="pre">a</span> <span class="pre">=</span> |
---|
368 | <span class="pre">minus</span></code> (respectively <code class="docutils literal"><span class="pre">a=plus</span></code>) then the option <code class="docutils literal"><span class="pre">-XX:-a</span></code> |
---|
369 | (respectivelly <code class="docutils literal"><span class="pre">-XX:+a</span></code>) will be passed.</td> |
---|
370 | </tr> |
---|
371 | <tr class="field-even field"><th class="field-name">[javax]:</th><td class="field-body">The section is used to pass -X* options to the JVM (see |
---|
372 | <a class="reference external" href="http://docs.oracle.com/cd/E22289_01/html/821-1274/configuring-the-default-jvm-and-java-arguments.html">ref.</a>). For |
---|
373 | each map <code class="docutils literal"><span class="pre">a</span> <span class="pre">=</span> <span class="pre">b</span></code> available in the <code class="docutils literal"><span class="pre">[javax]</span></code> section, the option |
---|
374 | <code class="docutils literal"><span class="pre">-Xab</span></code> will be passed to the JVM (ie. set <code class="docutils literal"><span class="pre">mx=2G</span></code> to pass |
---|
375 | <code class="docutils literal"><span class="pre">-Xmx2G</span></code>).</td> |
---|
376 | </tr> |
---|
377 | </tbody> |
---|
378 | </table> |
---|
379 | <div class="section" id="id1"> |
---|
380 | <h3>ZOO-API<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3> |
---|
381 | <p>Before you build your first ZOO-Service implemented in Java, it is |
---|
382 | recommended that you first build the ZOO class of the Java ZOO-API.</p> |
---|
383 | <div class="admonition note"> |
---|
384 | <p class="first admonition-title">Note</p> |
---|
385 | <p class="last">You should build ZOO-Kernel prior to follow this instructions.</p> |
---|
386 | </div> |
---|
387 | <p>To build the ZOO.class of the ZOO-API for Java, use the following |
---|
388 | command:</p> |
---|
389 | <div class="highlight-guess"><div class="highlight"><pre>cd zoo-api/java |
---|
390 | make |
---|
391 | cp ZOO.class libZOO.so /usr/lib/cgi-bin |
---|
392 | </pre></div> |
---|
393 | </div> |
---|
394 | <div class="admonition note"> |
---|
395 | <p class="first admonition-title">Note</p> |
---|
396 | <p class="last">running the previous commands will require that both |
---|
397 | <code class="docutils literal"><span class="pre">javac</span></code> and <code class="docutils literal"><span class="pre">javah</span></code> are in your PATH.</p> |
---|
398 | </div> |
---|
399 | </div> |
---|
400 | <div class="section" id="java-zcfg-requirements"> |
---|
401 | <h3>Java ZCFG requirements<a class="headerlink" href="#java-zcfg-requirements" title="Permalink to this headline">¶</a></h3> |
---|
402 | <div class="admonition note"> |
---|
403 | <p class="first admonition-title">Note</p> |
---|
404 | <p class="last">For each Service provided by your ZOO Java Services Provider |
---|
405 | (your corresponding Java class), the ZCFG File should have |
---|
406 | the name of the Java public method corresponding to the |
---|
407 | service (case-sensitive).</p> |
---|
408 | </div> |
---|
409 | <p>The ZCFG file should contain the following :</p> |
---|
410 | <dl class="docutils"> |
---|
411 | <dt>serviceType</dt> |
---|
412 | <dd>Java</dd> |
---|
413 | <dt>serviceProvider</dt> |
---|
414 | <dd>The name of the Java class to use as a ZOO Service Provider. For instance, if your |
---|
415 | java class, located in the same directory as your ZOO-Kernel, was |
---|
416 | named <code class="docutils literal"><span class="pre">HelloJava.class</span></code> then you should use <code class="docutils literal"><span class="pre">HelloJava</span></code>.</dd> |
---|
417 | </dl> |
---|
418 | </div> |
---|
419 | <div class="section" id="java-data-structure-used"> |
---|
420 | <h3>Java Data Structure used<a class="headerlink" href="#java-data-structure-used" title="Permalink to this headline">¶</a></h3> |
---|
421 | <p>The three parameters are passed to the Java function as |
---|
422 | <a class="reference external" href="http://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html">java.util.HashMap</a>.</p> |
---|
423 | </div> |
---|
424 | <div class="section" id="sample-zoo-java-services-provider"> |
---|
425 | <h3>Sample ZOO Java Services Provider<a class="headerlink" href="#sample-zoo-java-services-provider" title="Permalink to this headline">¶</a></h3> |
---|
426 | <div class="highlight-java"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">java.util.*</span><span class="o">;</span> |
---|
427 | <span class="kd">public</span> <span class="kd">class</span> <span class="nc">HelloJava</span> <span class="o">{</span> |
---|
428 | <span class="kd">public</span> <span class="kd">static</span> <span class="kt">int</span> <span class="nf">HelloWorldJava</span><span class="o">(</span><span class="n">HashMap</span> <span class="n">conf</span><span class="o">,</span><span class="n">HashMap</span> <span class="n">inputs</span><span class="o">,</span> <span class="n">HashMap</span> <span class="n">outputs</span><span class="o">)</span> <span class="o">{</span> |
---|
429 | <span class="n">HashMap</span> <span class="n">hm1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">();</span> |
---|
430 | <span class="n">hm1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"dataType"</span><span class="o">,</span><span class="s">"string"</span><span class="o">);</span> |
---|
431 | <span class="n">HashMap</span> <span class="n">tmp</span><span class="o">=(</span><span class="n">HashMap</span><span class="o">)(</span><span class="n">inputs</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"S"</span><span class="o">));</span> |
---|
432 | <span class="n">java</span><span class="o">.</span><span class="na">lang</span><span class="o">.</span><span class="na">String</span> <span class="n">v</span><span class="o">=</span><span class="n">tmp</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"value"</span><span class="o">).</span><span class="na">toString</span><span class="o">();</span> |
---|
433 | <span class="n">hm1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"value"</span><span class="o">,</span><span class="s">"Hello "</span><span class="o">+</span><span class="n">v</span><span class="o">+</span><span class="s">" from JAVA WOrld !"</span><span class="o">);</span> |
---|
434 | <span class="n">outputs</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Result"</span><span class="o">,</span><span class="n">hm1</span><span class="o">);</span> |
---|
435 | <span class="n">System</span><span class="o">.</span><span class="na">err</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Hello from JAVA WOrld !"</span><span class="o">);</span> |
---|
436 | <span class="k">return</span> <span class="n">ZOO</span><span class="o">.</span><span class="na">SERVICE_SUCCEEDED</span><span class="o">;</span> |
---|
437 | <span class="o">}</span> |
---|
438 | <span class="o">}</span> |
---|
439 | </pre></div> |
---|
440 | </div> |
---|
441 | </div> |
---|
442 | </div> |
---|
443 | <div class="section" id="javascript"> |
---|
444 | <h2>Javascript<a class="headerlink" href="#javascript" title="Permalink to this headline">¶</a></h2> |
---|
445 | <div class="section" id="id2"> |
---|
446 | <h3>ZOO API<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3> |
---|
447 | <p>If you need to use <span class="xref std std-ref">ZOO API</span> in your service, you have first to copy <code class="docutils literal"><span class="pre">zoo-api.js</span></code> |
---|
448 | and <code class="docutils literal"><span class="pre">zoo-proj4js.js</span></code> where your services are located (for example in Unix system probably in |
---|
449 | <code class="docutils literal"><span class="pre">/usr/lib/cgi-bin/</span></code></p> |
---|
450 | </div> |
---|
451 | <div class="section" id="javascript-zcfg-requirements"> |
---|
452 | <h3>Javascript ZCFG requirements<a class="headerlink" href="#javascript-zcfg-requirements" title="Permalink to this headline">¶</a></h3> |
---|
453 | <div class="admonition note"> |
---|
454 | <p class="first admonition-title">Note</p> |
---|
455 | <p class="last">For each Service provided by your ZOO Javascript Services Provider, the ZCFG File |
---|
456 | must be named the same as the Javascript function name (also the case of |
---|
457 | characters is important).</p> |
---|
458 | </div> |
---|
459 | <p>The ZCFG file should contain the following :</p> |
---|
460 | <dl class="docutils"> |
---|
461 | <dt>serviceType</dt> |
---|
462 | <dd>JS</dd> |
---|
463 | <dt>serviceProvider</dt> |
---|
464 | <dd>The name of the JavaScript file to use as a ZOO Service Provider. For instance, if your |
---|
465 | script, located in the same directory as your ZOO Kernel, was named <code class="docutils literal"><span class="pre">my_module.js</span></code> then |
---|
466 | you should use <code class="docutils literal"><span class="pre">my_module.js</span></code>.</dd> |
---|
467 | </dl> |
---|
468 | </div> |
---|
469 | <div class="section" id="javascript-data-structure-used"> |
---|
470 | <h3>Javascript Data Structure used<a class="headerlink" href="#javascript-data-structure-used" title="Permalink to this headline">¶</a></h3> |
---|
471 | <p>The three parameters of the function are passed to the JavaScript function as Object.</p> |
---|
472 | </div> |
---|
473 | <div class="section" id="sample-zoo-javascript-services-provider"> |
---|
474 | <h3>Sample ZOO Javascript Services Provider<a class="headerlink" href="#sample-zoo-javascript-services-provider" title="Permalink to this headline">¶</a></h3> |
---|
475 | <div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">hellojs</span><span class="p">(</span><span class="nx">conf</span><span class="p">,</span><span class="nx">inputs</span><span class="p">,</span><span class="nx">outputs</span><span class="p">){</span> |
---|
476 | <span class="nx">outputs</span><span class="o">=</span><span class="k">new</span> <span class="nb">Array</span><span class="p">();</span> |
---|
477 | <span class="nx">outputs</span><span class="o">=</span><span class="p">{};</span> |
---|
478 | <span class="nx">outputs</span><span class="p">[</span><span class="s2">"result"</span><span class="p">][</span><span class="s2">"value"</span><span class="p">]</span><span class="o">=</span><span class="s2">"Hello "</span><span class="o">+</span><span class="nx">inputs</span><span class="p">[</span><span class="s2">"S"</span><span class="p">][</span><span class="s2">"value"</span><span class="p">]</span><span class="o">+</span><span class="s2">" from JS World !"</span><span class="p">;</span> |
---|
479 | <span class="k">return</span> <span class="nb">Array</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="nx">outputs</span><span class="p">);</span> |
---|
480 | <span class="p">}</span> |
---|
481 | </pre></div> |
---|
482 | </div> |
---|
483 | </div> |
---|
484 | </div> |
---|
485 | </div> |
---|
486 | |
---|
487 | |
---|
488 | </div> |
---|
489 | <footer> |
---|
490 | |
---|
491 | <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
---|
492 | |
---|
493 | <a href="status.html" class="btn btn-neutral float-right" title="ZOO Status Service">Next <span class="fa fa-arrow-circle-right"></span></a> |
---|
494 | |
---|
495 | |
---|
496 | <a href="process-profiles.html" class="btn btn-neutral" title="Process profiles registry"><span class="fa fa-arrow-circle-left"></span> Previous</a> |
---|
497 | |
---|
498 | </div> |
---|
499 | |
---|
500 | |
---|
501 | <hr/> |
---|
502 | <div class="pfoot"> |
---|
503 | <div role="contentinfo"> |
---|
504 | <p> |
---|
505 | © Copyright 2009-2015, ZOO-Project team. |
---|
506 | </p> |
---|
507 | </div> |
---|
508 | Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> inspired by <a href="https://readthedocs.org">Read the Docs</a>. |
---|
509 | </div> |
---|
510 | </footer> |
---|
511 | |
---|
512 | </div> |
---|
513 | </div> |
---|
514 | |
---|
515 | </section> |
---|
516 | |
---|
517 | </div> |
---|
518 | |
---|
519 | |
---|
520 | |
---|
521 | |
---|
522 | |
---|
523 | <script type="text/javascript"> |
---|
524 | var DOCUMENTATION_OPTIONS = { |
---|
525 | URL_ROOT:'../', |
---|
526 | VERSION:'1.4a0', |
---|
527 | COLLAPSE_INDEX:false, |
---|
528 | FILE_SUFFIX:'.html', |
---|
529 | HAS_SOURCE: true |
---|
530 | }; |
---|
531 | </script> |
---|
532 | <script type="text/javascript" src="../_static/jquery.js"></script> |
---|
533 | <script type="text/javascript" src="../_static/underscore.js"></script> |
---|
534 | <script type="text/javascript" src="../_static/doctools.js"></script> |
---|
535 | |
---|
536 | |
---|
537 | |
---|
538 | |
---|
539 | |
---|
540 | <script type="text/javascript" src="../_static/js/theme.js"></script> |
---|
541 | |
---|
542 | |
---|
543 | |
---|
544 | |
---|
545 | <script type="text/javascript"> |
---|
546 | jQuery(function () { |
---|
547 | SphinxRtdTheme.StickyNav.enable(); |
---|
548 | }); |
---|
549 | </script> |
---|
550 | |
---|
551 | |
---|
552 | </body> |
---|
553 | </html> |
---|