Changeset 794


Ignore:
Timestamp:
Dec 27, 2016, 6:34:38 PM (4 years ago)
Author:
djay
Message:

Add the initial C# language support.

Location:
trunk
Files:
11 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/services/howtos.rst

    r771 r794  
    66:ref:`services_index` are quite easy to create once you have installed the ZOO Kernel and have
    77chosen code (in the language of your choice) to turn into a ZOO service. Here are some
    8 HelloWorlds in Python, PHP, Java  and JavaScript with links to their corresponding
     8HelloWorlds in Python, PHP, Java, C#  and JavaScript with links to their corresponding
    99``.zcfg`` files.
     10
     11
     12.. contents:: :depth: 3
    1013
    1114
     
    199202----
    200203
    201 Specifically for the Java support, you may add the following two
     204Specifically for the Java support, you may add the following three
    202205sections to your ``main.cfg`` file:
    203206
     
    311314  }
    312315
     316C#
     317----
     318
     319Specifically for the C# support, you should add the following
     320section to your ``main.cfg`` file.
     321
     322
     323:[mono]:
     324   This section is used to define both ``libPath`` and ``etcPath``
     325   required by the Mono .NET Framework.
     326
     327ZOO-API
     328*******
     329
     330Before you build your first ZOO-Service implemented in Mono, you
     331should first build the ``ZMaps.dll`` containing the Mono ZOO-API.
     332
     333.. Note:: You should build ZOO-Kernel prior to follow this instructions.
     334
     335.. code-block:: guess
     336
     337  cd zoo-api/mono
     338  make
     339
     340Then you should copy the ``ZMaps.dll`` in your ``servicePath`` or in
     341the directory where your ``zoo_loader.cgi`` file is stored.
     342
     343The ZOO-API is available from a C# class named ZOO_API and provides
     344the following static variables:
     345
     346:int SERVICE_SUCCEEDED:
     347   Value to return in case your service end successfully.
     348:int SERVICE_FAILED:
     349   Value to retrun in case of failure.
     350
     351The ZOO-API provides the following static functions:
     352
     353:string Translate(String s):
     354   This function call the internal ZOO-Kernel function responsible for
     355   searching a translation of ``s`` in the zoo-services dictionary.
     356
     357:void UpdateStatus(ZMaps conf,String pourcent,String message):
     358   This function call the updateStatus ZOO-Kernel function responsible
     359   for updating the status of the running service (only usefull when
     360   the service has been called asynchronously).
     361
     362
     363C# ZCFG requirements
     364**********************************
     365
     366.. Note:: For each Service provided by your ZOO Mono Services Provider
     367          (your corresponding Mono class), the ZCFG File should have
     368          the name of the Mono public static function corresponding to the
     369          service (case-sensitive).
     370
     371The ZCFG file should contain the following :
     372
     373serviceType
     374    Mono
     375serviceProvider
     376    The full name of the C# dll containing the ZOO-Service Provider
     377    (including ``.dll``).
     378serviceNameSpace
     379    The namespace of the C# class containing the ZOO-Service Provider.
     380serviceClass
     381    The name of the C# class containing the ZOO-Service Provider definition.
     382
     383C# Data Structure used
     384********************************
     385
     386The three parameters of the function are passed to the Mono static
     387function as ``ZMaps`` which are basically
     388``Dictionary<String,_ZMaps>``.
     389
     390Sample ZOO C# Services Provider
     391******************************************
     392
     393.. literalinclude:: ../../zoo-project/zoo-services/hello-mono/test.cs
     394   :language: csharp
     395   :lines: 24-100
     396
    313397Javascript
    314398----------
  • trunk/workshop/index.rst

    r752 r794  
    1212   :maxdepth: 1
    1313
     14   2016/index
    1415   2015/index
    1516   2014/index
  • trunk/zoo-project/HISTORY.txt

    r790 r794  
    11Version 1.6.0-dev
     2  * Add the C# as a supported programming language for Services
    23  * Add nested inputs and outputs support (WPS 2.0.0)
    34  * Add servicePath special key to specify the service location
  • trunk/zoo-project/zoo-kernel/Makefile.in

    r784 r794  
    8686        gcc -fPIC ${XML2CFLAGS} ${JSCFLAGS} ${CFLAGS} ${JS_ENABLED} -c service_internal_js.c
    8787
     88service_internal_mono.o: service_internal_mono.h service_internal_mono.c service.h
     89        gcc -c ${XML2CFLAGS} ${MONO_CFLAGS} ${CFLAGS} ${MONO_ENABLED} service_internal_mono.c
     90
    8891service_internal_ruby.o: service_internal_ruby.c service_internal_ruby.h
    8992        g++ ${XML2CFLAGS} ${RUBYCFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c service_internal_ruby.c
     
    9295        g++ -c ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} service_loader.c
    9396
    94 zoo_service_loader.o: zoo_service_loader.c service.h version.h ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE}
    95         g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${SAGA_ENABLED} ${OTB_ENABLED} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
     97zoo_service_loader.o: zoo_service_loader.c service.h version.h ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE}
     98        g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${MONO_CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${SAGA_ENABLED} ${OTB_ENABLED} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} ${MONO_ENABLED} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
    9699
    97100libzoo_service.${EXT}: version.h service_internal.o service.o sqlapi.o
     
    100103zoo_loader.cgi: version.h libzoo_service.${EXT} zoo_loader.c zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o request_parser.o response_print.o server_internal.o caching.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE}
    101104        g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS}  ${PERLCFLAGS} ${RUBYCFLAGS}  ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c  -fno-common -DPIC -o zoo_loader.o
    102         g++  ${JSCFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o ${MS_FILE} ${PYTHON_FILE}  ${PERL_FILE} ${PHP_FILE}  ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} response_print.o server_internal.o caching.o request_parser.o ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -L. ${LDFLAGS}
     105        g++  ${JSCFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o ${MS_FILE} ${PYTHON_FILE}  ${PERL_FILE} ${PHP_FILE}  ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE} response_print.o server_internal.o caching.o request_parser.o ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -L. ${LDFLAGS}
    103106
    104107zcfg2yaml: zcfg2yaml.c service.h lex.sr.o service_conf.tab.o service_conf.y main_conf_read.tab.o lex.cr.o response_print.o server_internal.o service_internal.o ${MS_FILE} ${YAML_FILE}
  • trunk/zoo-project/zoo-kernel/ZOOMakefile.opts.in

    r784 r794  
    9696SAGA_FILE=@SAGA_FILE@
    9797
     98MONO_CFLAGS=@MONO_CFLAGS@
     99MONO_LDFLAGS=@MONO_LDFLAGS@
     100MONO_ENABLED=@MONO_ENABLED@
     101MONO_FILE=@MONO_FILE@
     102
    98103CFLAGS=@RELY_ON_DB@ @DEB_DEF@ -fpic @OPENSSL_CFLAGS@ ${FCGI_CFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
    99 LDFLAGS=-lzoo_service @DEFAULT_LIBS@ -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS}  ${FCGI_LDFLAGS} @OPENSSL_LDFLAGS@ -luuid ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS}
     104LDFLAGS=-lzoo_service @DEFAULT_LIBS@ -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS}  ${FCGI_LDFLAGS} @OPENSSL_LDFLAGS@ -luuid ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS} ${MONO_LDFLAGS}
    100105
    101106DATAROOTDIR=@datarootdir@/zoo-project
  • trunk/zoo-project/zoo-kernel/configure.ac

    r784 r794  
    637637
    638638# ===========================================================================
     639# Detect if mono is installed
     640# ===========================================================================
     641
     642AC_ARG_WITH([mono],
     643        [AS_HELP_STRING([--with-mono=PATH], [To enable mono support, specify the path to find pkg-config,  disabled by default])],
     644        [MONOHOME="$withval"; MONO_ENABLED="-DUSE_MONO"], [MONO_ENABLED=""])
     645
     646if test -z "$MONO_ENABLED"
     647then
     648        MONO_FILE=""
     649else
     650        MONO_FILE="service_internal_mono.o"
     651        if test "x$MONOHOME" = "x";
     652        then
     653                MONOHOME="/usr"
     654        fi
     655        if test "x$MONOHOME" = "xyes";
     656        then
     657                MONOHOME="/usr"
     658        fi
     659
     660        # Extract the linker and include flags
     661        MONO_CFLAGS=`$MONOHOME/bin/pkg-config --cflags mono-2`
     662        MONO_LDFLAGS=`$MONOHOME/bin/pkg-config --libs mono-2`
     663
     664        AC_LANG([C++])
     665        echo $JAVA_CPPFLAGS
     666        # Check headers file (second time we check that in fact)
     667        CPPFLAGS_SAVE="$CFLAGS"
     668        CPPFLAGS="$MONO_CFLAGS"
     669        AC_CHECK_HEADERS([mono/jit/jit.h],
     670                         [], [AC_MSG_ERROR([could not find jit.h file])])
     671        CPPFLAGS="$CPPFLAGS_SAVE"
     672        # Ensure we can link against libmono-2.0
     673        LIBS_SAVE="$LIBS"
     674        LIBS="$MONO_LDFLAGS"
     675        AC_CHECK_LIB([mono-2.0], [mono_runtime_invoke], [], [AC_MSG_ERROR([could not find libmono])], [])
     676        LIBS="$LIBS_SAVE"
     677
     678        AC_SUBST([MONO_CFLAGS])
     679        AC_SUBST([MONO_LDFLAGS])
     680fi
     681
     682AC_SUBST([MONO_ENABLED])
     683AC_SUBST([MONO_FILE])
     684
     685# ===========================================================================
    639686# Detect if ruby is installed
    640687# ===========================================================================
  • trunk/zoo-project/zoo-kernel/request_parser.c

    r790 r794  
    16271627              cgiFilePtr file;
    16281628              int targetFile;
    1629               char storageNameOnServer[2048];
    1630               char fileNameOnServer[64];
     1629              char *storageNameOnServer;
     1630              char *fileNameOnServer;
    16311631              char contentType[1024];
    16321632              char buffer[1024];
     
    16511651                        break;
    16521652                    }
     1653                  fileNameOnServer=(char*)malloc((strlen(name) - t - 1 )*sizeof(char));
    16531654                  strcpy (fileNameOnServer, name + t + 1);
    16541655
     1656                  storageNameOnServer=(char*)malloc((strlen(path->value) + strlen(fileNameOnServer) + 2)*sizeof(char));
    16551657                  sprintf (storageNameOnServer, "%s/%s", path->value,
    16561658                           fileNameOnServer);
     
    16831685                  cgiFormFileClose (file);
    16841686                  close (targetFile);
     1687                  free(fileNameOnServer);
     1688                  free(storageNameOnServer);
    16851689#ifdef DEBUG
    16861690                  fprintf (stderr, "File \"%s\" has been uploaded",
  • trunk/zoo-project/zoo-kernel/service.c

    r790 r794  
    515515    free(tmp->value);
    516516  tmp->value=(char*)malloc((size+1)*sizeof(char));
    517   memmove(tmp->value,v,size*sizeof(char));
     517  if(v!=NULL)
     518    memmove(tmp->value,v,size*sizeof(char));
    518519  tmp->value[size]=0;
    519520  char sin[128];
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r790 r794  
    8181#ifdef USE_PERL
    8282#include "service_internal_perl.h"
     83#endif
     84
     85#ifdef USE_MONO
     86#include "service_internal_mono.h"
    8387#endif
    8488
     
    705709      *eres =
    706710        zoo_ruby_support (&m, request_inputs, s1, &request_input_real_format,
     711                          &request_output_real_format);
     712    }
     713  else
     714#endif
     715
     716#ifdef USE_MONO
     717  if (strncasecmp (r_inputs->value, "Mono", 4) == 0)
     718    {
     719      *eres =
     720        zoo_mono_support (&m, request_inputs, s1, &request_input_real_format,
    707721                          &request_output_real_format);
    708722    }
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

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