Index: tags/rel-1.2.0-rc3/zoo-kernel/Makefile.in
===================================================================
--- branches/branch-1.2/zoo-kernel/Makefile.in	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/Makefile.in	(revision 302)
@@ -2,5 +2,5 @@
 ifeq ($(OS),Darwin)
 	MACOS_LD_FLAGS=-lintl -framework SystemConfiguration -framework CoreFoundation
-	MACOS_CFLAGS=-arch i386 -arch ppc -arch x86_64
+	MACOS_CFLAGS=-arch $(shell uname -m)
 endif
 
Index: tags/rel-1.2.0-rc3/zoo-kernel/ZOOMakefile.opts.in
===================================================================
--- tags/rel-1.2.0-rc3/zoo-kernel/ZOOMakefile.opts.in	(revision 302)
+++ tags/rel-1.2.0-rc3/zoo-kernel/ZOOMakefile.opts.in	(revision 302)
@@ -0,0 +1,25 @@
+OS:=$(shell uname -s)
+ifeq ($(OS),Darwin)
+	MACOS_LD_FLAGS=-lintl
+	MACOS_LD_NET_FLAGS=-framework SystemConfiguration -framework CoreFoundation
+	MACOS_CFLAGS=-arch $(shell uname -m)
+endif
+
+GDAL_CFLAGS=@GDAL_CFLAGS@
+GDAL_LIBS=@GDAL_LIBS@
+
+XML2CFLAGS=@XML2_CPPFLAGS@
+XML2LDFLAGS=@XML2_LDFLAGS@
+
+PYTHONCFLAGS=@PYTHON_CPPFLAGS@
+PYTHONLDFLAGS=@PYTHON_LDFLAGS@
+
+JS_ENABLED=@JS_ENABLED@
+JSCFLAGS=@JS_CPPFLAGS@
+JSLDFLAGS=@JS_LDFLAGS@
+ifeq ($(JS_ENABLED),-DUSE_JS)
+     JS_LDFLAGS=${ZRPATH}/zoo-kernel/ulinet.o ${ZRPATH}/zoo-kernel/service_internal_js.o -lcurl 
+endif
+
+ZOO_CFLAGS=-I${ZRPATH}/thirds/cgic206/ -I${ZRPATH}/zoo-kernel/
+ZOO_LDFLAGS=-lcrypto
Index: tags/rel-1.2.0-rc3/zoo-kernel/configure.ac
===================================================================
--- branches/branch-1.2/zoo-kernel/configure.ac	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/configure.ac	(revision 302)
@@ -122,4 +122,8 @@
 	[PYTHON_PATH="$withval"; PYTHON_ENABLED="-DUSE_PYTHON"], [PYTHON_ENABLED=""])
 
+AC_ARG_WITH([pyvers], 
+	[AS_HELP_STRING([--with-pyvers=NUM], [To use a specific python version])], 
+	[PYTHON_VERS="$withval"], [PYTHON_VERS=""])
+
 
 if test -z "$PYTHON_ENABLED"
@@ -127,12 +131,12 @@
 	PYTHON_FILE=""
 else
-	PYTHONCONFIG="$PYTHON_PATH/bin/python-config"
+	PYTHONCONFIG="$PYTHON_PATH/bin/python${PYTHON_VERS}-config"
 	PYTHON_FILE="service_internal_python.o"
 	if test  "$PYTHON_PATH" = "yes"
 	then
 		# PHP was not specified, so search within the current path
-		AC_PATH_PROG([PYTHONCONFIG], [python-config])
-	else
-		PYTHONCONFIG="$PYTHON_PATH/bin/python-config"
+		AC_PATH_PROG([PYTHONCONFIG], [python${PYTHON_VERS}-config])
+	else
+		PYTHONCONFIG="$PYTHON_PATH/bin/python${PYTHON_VERS}-config"
 	fi
 
@@ -314,18 +318,18 @@
 	JS_FILE=""
 else
+	JS_FILE="service_internal_js.o"
 	if test "$JSHOME" = "yes"
 	then
-        	JS_FILE="service_internal_js.o"
 
 		#on teste si on est sous debian like 
 		if test -f "/usr/bin/dpkg"
 		then
-			if test -n "`dpkg -l | grep libmozjs-dev`"
+			if test -n "`dpkg -l | grep libmozjs185-dev`"
 			then
-				JS_CPPFLAGS="-I/usr/include/mozjs/"
-                        	JS_LDFLAGS="-L/usr/lib -lmozjs -lm"
-                        	JS_LIB="mozjs"
+				JS_CPPFLAGS="-I/usr/include/js/"
+                        	JS_LDFLAGS="-L/usr/lib -lmozjs185 -lm"
+                        	JS_LIB="mozjs185"
 			else 
-				XUL_VERSION="`dpkg -l | grep xulrunner | grep dev | awk '{print $3;}' | sed -e 's/\([[0-9]]\{1,2\}\.[[0-9]]\{1,2\}\.[[0-9]]\{1,2\}\.[[0-9]]\{1,2\}\).*/\1/'`"
+				XUL_VERSION="`dpkg -l | grep xulrunner | grep dev | head -1| awk '{print $3;}' | cut -d'+' -f1`"
 				if test -n "$XUL_VERSION"
 				then
@@ -334,14 +338,14 @@
 					JS_LIB="mozjs"
 				else
-					AC_MSG_ERROR([You must install libmozjs-dev or xulrunner-dev ])
+					AC_MSG_ERROR([You must install libmozjs185-dev or xulrunner-dev ])
 				fi
 			fi
 		else
-			AC_MSG_ERROR([You must  specify your custom install of libjs])
+			AC_MSG_ERROR([You must  specify your custom install of libmozjs185])
 		fi
 	else
-		JS_CPPFLAGS="-I$JSHOME/include/"
-                JS_LDFLAGS="-L$JSHOME/lib -lmozjs -lm"
-                JS_LIB="mozjs"
+		JS_CPPFLAGS="-I$JSHOME/include/js/"
+                JS_LDFLAGS="-L$JSHOME/lib -lmozjs185 -lm"
+                JS_LIB="mozjs185"
 
 	fi 
@@ -356,5 +360,5 @@
         LIBS="$JS_LDFLAGS"
 
-        AC_CHECK_LIB([$JS_LIB], [JS_CallFunctionName], [], [AC_MSG_ERROR([could not find $JS_LIB])], [])
+        AC_CHECK_LIB([$JS_LIB], [JS_CompileFile,JS_CallFunctionName], [], [AC_MSG_ERROR([could not find $JS_LIB])], [])
 			
         AC_SUBST([JS_CPPFLAGS])
@@ -366,3 +370,4 @@
 
 AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([ZOOMakefile.opts])
 AC_OUTPUT
Index: tags/rel-1.2.0-rc3/zoo-kernel/service.h
===================================================================
--- branches/branch-1.2/zoo-kernel/service.h	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/service.h	(revision 302)
@@ -203,4 +203,5 @@
   }
 
+
   static map* getLastMap(map* m){
     map* tmp=m;
@@ -497,4 +498,17 @@
   }
 
+  static map* getMapOrFill(map* m,const char *key,char* value){
+    map* tmp=m;
+    map* tmpMap=getMap(tmp,key);
+    if(tmpMap==NULL){
+      if(tmp!=NULL)
+	addToMap(tmp,key,value);
+      else
+	tmp=createMap(key,value);
+      tmpMap=getMap(tmp,key);
+    }
+    return tmpMap;
+  }
+
   static bool contains(map* m,map* i){
     while(i!=NULL){      
Index: tags/rel-1.2.0-rc3/zoo-kernel/service_internal.c
===================================================================
--- branches/branch-1.2/zoo-kernel/service_internal.c	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/service_internal.c	(revision 302)
@@ -258,6 +258,7 @@
 
 JSBool
-JSUpdateStatus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+JSUpdateStatus(JSContext *cx, uintN argc, jsval *argv1)
 {
+  jsval *argv = JS_ARGV(cx,argv1);
   JS_MaybeGC(cx);
   char *sid;
@@ -280,6 +281,9 @@
   }
   if(getMapFromMaps(conf,"lenv","status")!=NULL){
-    if(status!=NULL)
+    fprintf(stderr,"STATUS RETURNED : %s\n",status);
+    if(status!=NULL){
       setMapInMaps(conf,"lenv","status",status);
+      free(status);
+    }
     else
       setMapInMaps(conf,"lenv","status","15");
@@ -367,4 +371,5 @@
 #endif
   int currId=-1;
+  int currNode=-1;
   if(nbNs==0){
     nbNs++;
@@ -399,4 +404,28 @@
   }
   nbNs=0;
+}
+
+xmlNodePtr soapEnvelope(maps* conf,xmlNodePtr n){
+  map* soap=getMapFromMaps(conf,"main","isSoap");
+  if(soap!=NULL && strcasecmp(soap->value,"true")==0){
+    int lNbNs=nbNs;
+    nsName[lNbNs]=strdup("soap");
+    usedNs[lNbNs]=xmlNewNs(NULL,BAD_CAST "http://www.w3.org/2003/05/soap-envelope",BAD_CAST "soap");
+    nbNs++;
+    xmlNodePtr nr = xmlNewNode(usedNs[lNbNs], BAD_CAST "Envelope");
+    nsName[nbNs]=strdup("soap");
+    usedNs[nbNs]=xmlNewNs(nr,BAD_CAST "http://www.w3.org/2003/05/soap-envelope",BAD_CAST "soap");
+    nbNs++;
+    nsName[nbNs]=strdup("xsi");
+    usedNs[nbNs]=xmlNewNs(nr,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
+    nbNs++;
+    xmlNsPtr ns_xsi=usedNs[nbNs-1];
+    xmlNewNsProp(nr,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.w3.org/2003/05/soap-envelope http://www.w3.org/2003/05/soap-envelope");
+    xmlNodePtr nr1 = xmlNewNode(usedNs[lNbNs], BAD_CAST "Body");
+    xmlAddChild(nr1,n);
+    xmlAddChild(nr,nr1);
+    return nr;
+  }else
+    return n;
 }
 
@@ -715,5 +744,6 @@
   xmlAddChild(n,nc1);
   
-  xmlDocSetRootElement(doc, n);
+  xmlNodePtr fn=soapEnvelope(m,n);
+  xmlDocSetRootElement(doc, fn);
   //xmlFreeNs(ns);
   free(SERVICE_URL);
@@ -775,5 +805,6 @@
   addLangAttr(n,m);
 
-  xmlDocSetRootElement(doc, n);
+  xmlNodePtr fn=soapEnvelope(m,n);
+  xmlDocSetRootElement(doc, fn);
 
   return n;
@@ -1003,5 +1034,9 @@
 	}
     }
+
     _tmp=e->supported;
+    if(_tmp==NULL && (getMap(e->defaults->content,"uom")!=NULL || datatype!=1))
+      _tmp=e->defaults;
+
     int hasSupported=-1;
     while(_tmp!=NULL){
@@ -1082,6 +1117,4 @@
       if(hasDefault!=true && strncmp(type,"Input",5)==0)
 	xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue"));
-      xmlFreeNodeList(nc5);
-      xmlFreeNodeList(nc4);
     }
     
@@ -1093,5 +1126,5 @@
 
 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){
-  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
+  xmlNsPtr ns,ns1,ns_ows,ns_xlink,ns_xsi;
   xmlNodePtr nr,n,nc,nc1,nc2,nc3,pseudor;
   xmlDocPtr doc;
@@ -1100,4 +1133,5 @@
   time_t time1;  
   time(&time1);
+  nr=NULL;
   /**
    * Create the document and its temporary root.
@@ -1106,6 +1140,7 @@
   int wpsId=zooXmlAddNs(NULL,"http://www.opengis.net/wps/1.0.0","wps");
   ns=usedNs[wpsId];
-  
+
   n = xmlNewNode(ns, BAD_CAST "ExecuteResponse");
+  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
   int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
   ns_ows=usedNs[owsId];
@@ -1114,6 +1149,5 @@
   int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
   ns_xsi=usedNs[xsiId];
-  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
-
+  
   xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_response.xsd");
   
@@ -1159,5 +1193,5 @@
 	sprintf(currentSid,"%s",tmp_lenv->value);
       if(tmpm==NULL || strcasecmp(tmpm->value,"false")==0){
-	sprintf(url,"%s/?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid);
+	sprintf(url,"%s?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid);
       }else{
 	if(strlen(tmpm->value)>0)
@@ -1176,5 +1210,5 @@
     }
     if(tmpm1!=NULL)
-      sprintf(tmp,"%s/",tmpm1->value);
+      sprintf(tmp,"%s",tmpm1->value);
     tmpm1=getMapFromMaps(m,"main","TmpPath");
     sprintf(stored_path,"%s/%s_%i.xml",tmpm1->value,service,pid);
@@ -1312,5 +1346,7 @@
     while(mcursor!=NULL){
       scursor=getElements(serv->outputs,mcursor->name);
-      printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output");
+      if(scursor!=NULL){
+	printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output");
+      }
       mcursor=mcursor->next;
     }
@@ -1320,5 +1356,7 @@
   fprintf(stderr,"printProcessResponse 1 202\n");
 #endif
-  xmlDocSetRootElement(doc, n);
+  nr=soapEnvelope(m,n);
+  xmlDocSetRootElement(doc, nr);
+
   if(hasStoredExecuteResponse==true){
     /* We need to write the ExecuteResponse Document somewhere */
@@ -1525,5 +1563,7 @@
 	 || (tmp2!=NULL && (strncmp(tmp2->value,"image/",6)==0 ||
 			    (strncmp(tmp2->value,"application/",12)==0) &&
-			    strncmp(tmp2->value,"application/json",16)!=0))) {
+			    strncmp(tmp2->value,"application/json",16)!=0&&
+			    strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0)
+	     )) {
 	map* rs=getMap(m->content,"size");
 	bool isSized=true;
@@ -1531,5 +1571,5 @@
 	  char tmp1[1024];
 	  sprintf(tmp1,"%d",strlen(toto->value));
-	  rs=createMap("z",tmp1);
+	  rs=createMap("size",tmp1);
 	  isSized=false;
 	}
@@ -1541,10 +1581,19 @@
 	}
       }
-      else if(tmp!=NULL){
-	if(strncmp(tmp->value,"text/js",4)==0 ||
-	   strncmp(tmp->value,"application/js",14)==0)
+      else if(tmp2!=NULL){
+	if(strncmp(tmp2->value,"text/js",7)==0 ||
+	   strncmp(tmp2->value,"application/json",16)==0)
 	  xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value)));
-	else
-	  xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
+	else{
+	  if(strncmp(tmp2->value,"text/xml",8)==0 ||
+	     strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0){
+	    xmlDocPtr doc =
+	      xmlParseMemory(BAD_CAST toto->value,strlen(BAD_CAST toto->value));
+	    xmlNodePtr ir = xmlDocGetRootElement(doc);
+	    xmlAddChild(nc3,ir);
+	  }
+	  else
+	    xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
+	}
 	xmlAddChild(nc2,nc3);
       }
@@ -1764,4 +1813,6 @@
 	    else if(strcasecmp(mtype->value,"application/json")==0)
 	      ext=createMap("extension","js");
+	    else if(strncmp(mtype->value,"application/vnd.google-earth.kml",32)!=0)
+	      ext=createMap("extension","kml");
 	    else
 	      ext=createMap("extension","txt");
@@ -1953,4 +2004,12 @@
   elements* tmpInputs=in;
   maps* out1=*out;
+  if(type==1){
+    while(out1!=NULL){
+      if(getElements(in,out1->name)==NULL)
+	return out1->name;
+      out1=out1->next;
+    }
+    out1=*out;
+  }
   while(tmpInputs!=NULL){
     maps *tmpMaps=getMaps(out1,tmpInputs->name);
@@ -2082,4 +2141,5 @@
       else
 	addToMap(tmpMaps->content,"inRequest","true");
+
     }
     tmpInputs=tmpInputs->next;
@@ -2236,2 +2296,119 @@
   
 }
+
+
+unsigned char* getMd5(char* url){
+  EVP_MD_CTX md5ctx;
+  unsigned char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char));
+  unsigned char result[EVP_MAX_MD_SIZE];
+  unsigned int len;
+  EVP_DigestInit(&md5ctx, EVP_md5());
+  EVP_DigestUpdate(&md5ctx, url, strlen(url));
+  EVP_DigestFinal_ex(&md5ctx,result,&len);
+  EVP_MD_CTX_cleanup(&md5ctx);
+  int i;
+  for(i = 0; i < len; i++){
+    if(i>0){
+      char *tmp=strdup(fresult);
+      sprintf(fresult,"%s%02x", tmp,result[i]);
+      free(tmp);
+    }
+    else
+      sprintf(fresult,"%02x",result[i]);
+  }
+  return fresult;
+}
+
+/**
+ * Cache a file for a given request
+ */
+void addToCache(maps* conf,char* request,char* content,int length){
+  map* tmp=getMapFromMaps(conf,"main","cacheDir");
+  if(tmp!=NULL){
+    unsigned char* md5str=getMd5(request);
+    char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6));
+    sprintf(fname,"%s/%s.zca",tmp->value,md5str);
+#ifdef DEBUG
+    fprintf(stderr,"Cache list : %s\n",fname);
+    fflush(stderr);
+#endif
+    FILE* fo=fopen(fname,"w+");
+    fwrite(content,sizeof(char),length,fo);
+    fclose(fo);
+    free(md5str);
+    free(fname);
+  }
+}
+
+char* isInCache(maps* conf,char* request){
+  map* tmpM=getMapFromMaps(conf,"main","cacheDir");
+  if(tmpM!=NULL){
+    unsigned char* md5str=getMd5(request);
+#ifdef DEBUG
+    fprintf(stderr,"MD5STR : (%s)\n\n",md5str);
+#endif
+    char* fname=(char*)malloc(sizeof(char)*(strlen(tmpM->value)+38));
+    sprintf(fname,"%s/%s.zca",tmpM->value,md5str);
+    struct stat f_status;
+    int s=stat(fname, &f_status);
+    if(s==0 && f_status.st_size>0){
+      free(md5str);
+      return fname;
+    }
+    free(md5str);
+    free(fname);
+  }
+  return NULL;
+}
+
+/**
+ * loadRemoteFile:
+ * Try to load file from cache or download a remote file if not in cache
+ */
+void loadRemoteFile(maps* m,map* content,HINTERNET hInternet,char *url){
+  HINTERNET res;
+  char* fcontent;
+  char* cached=isInCache(m,url);
+  int fsize;
+  if(cached!=NULL){
+    struct stat f_status;
+    int s=stat(cached, &f_status);
+    if(s==0){
+      fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
+      FILE* f=fopen(cached,"r");
+      fread(fcontent,sizeof(char),f_status.st_size,f);
+      fsize=f_status.st_size;
+    }
+  }else{
+    res=InternetOpenUrl(hInternet,url,NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
+    fcontent=(char*)calloc((res.nDataLen+1),sizeof(char));
+    if(fcontent == NULL){
+      return errorException(m, _("Unable to allocate memory."), "InternalError");
+    }
+    size_t dwRead;
+    InternetReadFile(res, (LPVOID)fcontent, res.nDataLen, &dwRead);
+    fcontent[res.nDataLen]=0;
+    fsize=res.nDataLen;
+  }
+  map* tmpMap=getMapOrFill(content,"value","");
+  free(tmpMap->value);
+  tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
+  memcpy(tmpMap->value,fcontent,(fsize)*sizeof(char)); 
+  char ltmp1[256];
+  sprintf(ltmp1,"%d",fsize);
+  addToMap(content,"size",ltmp1);
+  if(cached==NULL)
+    addToCache(m,url,fcontent,fsize);
+  free(fcontent);
+  free(cached);
+}
+
+int errorException(maps *m, const char *message, const char *errorcode) 
+{
+  map* errormap = createMap("text", message);
+  addToMap(errormap,"code", errorcode);
+  printExceptionReportResponse(m,errormap);
+  freeMap(&errormap);
+  free(errormap);
+  return -1;
+}
Index: tags/rel-1.2.0-rc3/zoo-kernel/service_internal.h
===================================================================
--- branches/branch-1.2/zoo-kernel/service_internal.h	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/service_internal.h	(revision 302)
@@ -53,4 +53,5 @@
 #include "service.h"
 #include <openssl/sha.h>
+#include <openssl/md5.h>
 #include <openssl/hmac.h>
 #include <openssl/evp.h>
@@ -59,4 +60,5 @@
 
 #include "cgic.h"
+#include "ulinet.h"
 
 extern   int getServiceFromFile(const char*,service**);
@@ -72,7 +74,9 @@
 #endif
 #include <libxml/parser.h>
+#include <libxml/xpath.h>
+
   static char* SERVICE_URL;
-  static xmlNsPtr usedNs[5];
-  static char* nsName[5];
+  static xmlNsPtr usedNs[10];
+  static char* nsName[10];
   static int nbNs=0;
 
@@ -83,5 +87,5 @@
 #ifdef USE_JS
   char* JSValToChar(JSContext*,jsval*);
-  JSBool JSUpdateStatus(JSContext*,JSObject*,uintN,jsval *,jsval *);
+  JSBool JSUpdateStatus(JSContext*,uintN,jsval *);
 #endif
   
@@ -118,7 +122,12 @@
   char* addDefaultValues(maps**,elements*,maps*,int);
 
-  /*defined in zoo_loader.c*/ 
   int errorException(maps *m, const char *message, const char *errorcode);
 
+  int checkForSoapEnvelope(xmlDocPtr);
+
+  void addToCache(maps*,char*,char*,int);
+  char* isInCache(maps*,char*);
+  void loadRemoteFile(maps*,map*,HINTERNET,char*);
+  
 #ifdef __cplusplus
 }
Index: tags/rel-1.2.0-rc3/zoo-kernel/service_internal_js.c
===================================================================
--- branches/branch-1.2/zoo-kernel/service_internal_js.c	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/service_internal_js.c	(revision 302)
@@ -27,4 +27,19 @@
 static char dbg[1024];
 
+JSBool
+JSAlert(JSContext *cx, uintN argc, jsval *argv1)
+{
+  jsval *argv = JS_ARGV(cx,argv1);
+  int i=0;
+  JS_MaybeGC(cx);
+  for(i=0;i<argc;i++){
+    JSString* jsmsg = JS_ValueToString(cx,argv[i]);
+    fprintf(stderr,"[ZOO-API:JS] %s\n",JS_EncodeString(cx,jsmsg));
+  }
+  JS_MaybeGC(cx);
+  
+  return JS_TRUE;
+}
+
 int zoo_js_support(maps** main_conf,map* request,service* s,
 		   maps **inputs,maps **outputs)
@@ -57,13 +72,11 @@
     return 1;
   }
-  JS_SetOptions(cx, JSOPTION_VAROBJFIX);
+  JS_SetOptions(cx, JSOPTION_VAROBJFIX | JSOPTION_JIT );//| JSOPTION_METHODJIT);
   JS_SetVersion(cx, JSVERSION_LATEST);
   JS_SetErrorReporter(cx, reportError);
 
   /* Create the global object. */
-  global = JS_NewObject(cx, &global_class, NULL, NULL);
-  if (global == NULL){
-    return 1;
-  }
+  //global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
+  global = JS_NewObject(cx, &global_class, NULL,NULL);
 
   /* Populate the global object with the standard globals,
@@ -72,7 +85,10 @@
     return 1;
   }
+
   if (!JS_DefineFunction(cx, global, "ZOORequest", JSRequest, 4, 0))
     return 1;
   if (!JS_DefineFunction(cx, global, "ZOOUpdateStatus", JSUpdateStatus, 2, 0))
+    return 1;
+  if (!JS_DefineFunction(cx, global, "alert", JSAlert, 2, 0))
     return 1;
 
@@ -86,12 +102,16 @@
   char api0[strlen(tmpm1->value)+strlen(ntmp)+15];
   sprintf(api0,"%s/%sZOO-proj4js.js",ntmp,tmpm1->value);
+#ifdef JS_DEBUG
   fprintf(stderr,"Trying to load %s\n",api0);
-  JSScript *api_script1=loadZooApiFile(cx,global,api0);
+#endif
+  JSObject *api_script1=loadZooApiFile(cx,global,api0);
   fflush(stderr);
 
   char api1[strlen(tmpm1->value)+strlen(ntmp)+11];
   sprintf(api1,"%s/%sZOO-api.js",ntmp,tmpm1->value);
+#ifdef JS_DEBUG
   fprintf(stderr,"Trying to load %s\n",api1);
-  JSScript *api_script2=loadZooApiFile(cx,global,api1);
+#endif
+  JSObject *api_script2=loadZooApiFile(cx,global,api1);
   fflush(stderr);
 
@@ -106,5 +126,7 @@
   sprintf(filename,"%s/%s%s",ntmp,tmpm1->value,tmpm2->value);
   filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+1]=0;
+#ifdef JS_DEBUG
   fprintf(stderr,"FILENAME %s\n",filename);
+#endif
   struct stat file_status;
   stat(filename, &file_status);
@@ -112,7 +134,6 @@
   uint16 lineno;
   jsval rval;
-  FILE *jsfile=fopen(filename,"r");
   JSBool ok ;
-  JSScript *script = JS_CompileFileHandle(cx, global, filename,jsfile);
+  JSObject *script = JS_CompileFile(cx, global, filename);
   if(script!=NULL){
     (void)JS_ExecuteScript(cx, global, script, &rval);
@@ -127,5 +148,4 @@
     JS_DestroyRuntime(rt);
     JS_ShutDown();
-    fclose(jsfile);
     exit(-1);
   }
@@ -161,6 +181,8 @@
     if(strlen(dbg)==0)
       sprintf(dbg,"No result was found after the function call");
-    sprintf(tmp1,"Unable to run %s from the JavScript file %s : \n %s",s->name,filename,dbg);
+    sprintf(tmp1,"Unable to run %s from the JavaScript file %s : \n %s",s->name,filename,dbg);
+#ifdef JS_DEBUG
     fprintf(stderr,"%s",tmp1);
+#endif
     map* err=createMap("text",tmp1);
     addToMap(err,"code","NoApplicableCode");
@@ -211,4 +233,5 @@
     jsval tmp2;
     JSBool hasElement=JS_GetProperty(cx,d,"outputs",&tmp2);
+#ifdef JS_DEBUG
     if(!hasElement)
       fprintf(stderr,"No outputs property returned\n");
@@ -217,19 +240,13 @@
     else
       fprintf(stderr,"outputs is not an array as expected\n");
+#endif
     *outputs=mapsFromJSObject(cx,tmp2);
 #ifdef JS_DEBUG
-    dumpMaps(out);
+    dumpMaps(outputs);
 #endif
   }
 
   /* Cleanup. */
-  JS_DestroyScript(cx, script);
-  JS_DestroyScript(cx, api_script1);
-  JS_DestroyScript(cx, api_script2);
-  //JS_MaybeGC(cx);
-  // If we use the DestroyContext as requested to release memory then we get 
-  // issue getting back the main configuration maps after coming back to the 
-  // runRequest function ...
-  //JS_DestroyContext(cx);
+  JS_DestroyContext(cx);
   JS_DestroyRuntime(rt);
   JS_ShutDown();
@@ -240,22 +257,27 @@
 }
 
-JSScript * loadZooApiFile(JSContext *cx,JSObject  *global, char* filename){
+JSObject * loadZooApiFile(JSContext *cx,JSObject  *global, char* filename){
   struct stat api_status;
   int s=stat(filename, &api_status);
   if(s==0){
     jsval rval;
-    FILE *jsfile=fopen(filename,"r");
     JSBool ok ;
-    JSScript *script = JS_CompileFileHandle(cx, global, filename,jsfile);
+    JSObject *script = JS_CompileFile(cx, JS_GetGlobalObject(cx), filename);
     if(script!=NULL){
-      (void)JS_ExecuteScript(cx, global, script, &rval);
+      (void)JS_ExecuteScript(cx, JS_GetGlobalObject(cx), script, &rval);
+#ifdef JS_DEBUG
       fprintf(stderr,"**************\n%s correctly loaded\n**************\n",filename);
+#endif
       return script;
     }
+#ifdef JS_DEBUG
     else
       fprintf(stderr,"\n**************\nUnable to run %s\n**************\n",filename);
-  }
+#endif
+  }
+#ifdef JS_DEBUG
   else
     fprintf(stderr,"\n**************\nUnable to load %s\n**************\n",filename);
+#endif
   return NULL;
 }
@@ -288,5 +310,5 @@
   map* tmpm=t;
   while(tmpm!=NULL){
-    jsval jsstr = STRING_TO_JSVAL(JS_NewString(cx,tmpm->value,strlen(tmpm->value)));
+    jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm->value,strlen(tmpm->value)));
     JS_SetProperty(cx, res, tmpm->name,&jsstr);
 #ifdef JS_DEBUG
@@ -335,4 +357,9 @@
       fprintf(stderr,"Properties length :  %d \n",idp->length);
 #endif
+      tres=(maps*)malloc(MAPS_SIZE);
+      tres->name=NULL;
+      tres->content=NULL;
+      tres->next=NULL;
+
       for (index=0,argNum=idp->length;index<argNum;index++) { 
 	jsval id = idp->vector[index];
@@ -346,11 +373,13 @@
 	len1 = JS_GetStringLength(jsmsg);
 #ifdef JS_DEBUG
-	fprintf(stderr,"Enumerate id : %d => %s\n",oi,JS_GetStringBytes(jsmsg));
+	fprintf(stderr,"Enumerate id : %d => %s\n",oi,JS_EncodeString(cx,jsmsg));
 #endif
 	jsval nvp=JSVAL_NULL;
-	if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tmp1), JS_GetStringBytes(jsmsg), &nvp)==JS_FALSE))
-#ifdef JS_DEBUG
-	fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,JS_GetStringBytes(jsmsg));
-#endif
+	if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tmp1), JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){
+#ifdef JS_DEBUG
+	  fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,JS_EncodeString(cx,jsmsg));
+#endif
+	}
+	
 	if(JSVAL_IS_OBJECT(nvp)){
 #ifdef JS_DEBUG
@@ -358,32 +387,30 @@
 #endif
 	}
-#ifdef JS_DEBUG
-	else
-	  fprintf(stderr,"JSVAL NVP IS NOT OBJECT !!\n");
-#endif
-	JSObject *nvp1;
+
+	JSObject *nvp1=JSVAL_NULL;
 	JS_ValueToObject(cx,nvp,&nvp1);
 	jsval nvp1j=OBJECT_TO_JSVAL(nvp1);
 	if(JSVAL_IS_OBJECT(nvp1j)){
-#ifdef JS_DEBUG
-	  fprintf(stderr,"JSVAL NVP1J IS OBJECT\n");
-#endif
-	  tres=(maps*)malloc(MAPS_SIZE);
-	  tres->name=strdup(JS_GetStringBytes(jsmsg));
-	  tres->content=mapFromJSObject(cx,nvp1j);
-	  tres->next=NULL;
-#ifdef JS_DEBUG
-	  dumpMaps(res);
-#endif
-	  if(res==NULL)
-	    res=dupMaps(&tres);
+	  JSString *jsmsg1;
+	  JSObject *nvp2=JSVAL_NULL;
+	  jsmsg1 = JS_ValueToString(cx,nvp1j);
+	  len1 = JS_GetStringLength(jsmsg1);
+#ifdef JS_DEBUG
+	  fprintf(stderr,"JSVAL NVP1J IS OBJECT %s = %s\n",JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
+#endif
+	  if(strcasecmp(JS_EncodeString(cx,jsmsg1),"[object Object]")==0){
+	    tres->name=strdup(JS_EncodeString(cx,jsmsg));
+	    tres->content=mapFromJSObject(cx,nvp1j);
+	  }
 	  else
-	    addMapsToMaps(&res,tres);
-	  freeMaps(&tres);
-	  free(tres);
-	  tres=NULL;
-#ifdef JS_DEBUG
-	  dumpMaps(res);
-#endif
+	    if(strcasecmp(JS_EncodeString(cx,jsmsg),"name")==0){
+	      tres->name=strdup(JS_EncodeString(cx,jsmsg1));
+	    }
+	    else{
+	      if(tres->content==NULL)
+		tres->content=createMap(JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
+	      else
+		addToMap(tres->content,JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
+	    }
 	}
 #ifdef JS_DEBUG
@@ -391,5 +418,17 @@
 	  fprintf(stderr,"JSVAL NVP1J IS NOT OBJECT !!\n");
 #endif
+
       }
+#ifdef JS_DEBUG
+      dumpMaps(tres);
+#endif
+      if(res==NULL)
+	res=dupMaps(&tres);
+      else
+	addMapsToMaps(&res,tres);
+      freeMaps(&tres);
+      free(tres);
+      tres=NULL;
+
     }
   }
@@ -423,18 +462,18 @@
       len = JS_GetStringLength(jsmsg);
       jsval nvp;
-      JS_GetProperty(cx, JSVAL_TO_OBJECT(t), JS_GetStringBytes(jsmsg), &nvp);
+      JS_GetProperty(cx, JSVAL_TO_OBJECT(t), JS_EncodeString(cx,jsmsg), &nvp);
       jsmsg1 = JS_ValueToString(cx,nvp);
       len1 = JS_GetStringLength(jsmsg1);
 #ifdef JS_DEBUG
-      fprintf(stderr,"Enumerate id : %d [ %s => %s ]\n",index,JS_GetStringBytes(jsmsg),JS_GetStringBytes(jsmsg1));
+      fprintf(stderr,"Enumerate id : %d [ %s => %s ]\n",index,JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
 #endif
       if(res!=NULL){
 #ifdef JS_DEBUG
-	fprintf(stderr,"%s - %s\n",JS_GetStringBytes(jsmsg),JS_GetStringBytes(jsmsg1));
-#endif
-	addToMap(res,JS_GetStringBytes(jsmsg),JS_GetStringBytes(jsmsg1));
+	fprintf(stderr,"%s - %s\n",JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
+#endif
+	addToMap(res,JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
       }
       else{
-	res=createMap(JS_GetStringBytes(jsmsg),JS_GetStringBytes(jsmsg1));
+	res=createMap(JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
 	res->next=NULL;
       }
Index: tags/rel-1.2.0-rc3/zoo-kernel/service_internal_js.h
===================================================================
--- branches/branch-1.2/zoo-kernel/service_internal_js.h	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/service_internal_js.h	(revision 302)
@@ -52,5 +52,5 @@
   int zoo_js_support(maps**,map*,service*,maps **,maps **);
 
-  JSScript *loadZooApiFile(JSContext*,JSObject*,char*);
+  JSObject *loadZooApiFile(JSContext*,JSObject*,char*);
 
 #ifdef __cplusplus
Index: tags/rel-1.2.0-rc3/zoo-kernel/service_internal_python.c
===================================================================
--- branches/branch-1.2/zoo-kernel/service_internal_python.c	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/service_internal_python.c	(revision 302)
@@ -74,5 +74,11 @@
   free(pythonpath);
 
+  PyThreadState *mainstate;
+  PyEval_InitThreads();
   Py_Initialize();
+  mainstate = PyThreadState_Swap(NULL);
+  PyEval_ReleaseLock();
+  PyGILState_STATE gstate;
+  gstate = PyGILState_Ensure();
   PyObject *pName, *pModule, *pFunc;
   tmp=getMap(s->content,"serviceProvider");
@@ -119,11 +125,4 @@
 	dumpMaps(outputs);
 #endif
-	Py_DECREF(arg1);
-	Py_DECREF(arg2);
-	Py_DECREF(arg3);
-      	Py_DECREF(pArgs);
-	Py_DECREF(pValue);
-	Py_XDECREF(pFunc);
-	Py_DECREF(pModule);
       }else{	  
 	PyObject *ptype,*pvalue, *ptraceback;
@@ -159,27 +158,13 @@
 	addToMap(err,"code","NoApplicableCode");
 	printExceptionReportResponse(m,err);
-	Py_DECREF(arg1);
-	Py_DECREF(arg2);
-	Py_DECREF(arg3);
-	Py_XDECREF(pFunc);
-      	Py_DECREF(pArgs);
-	Py_DECREF(pModule);
-	Py_DECREF(ptraceback);
-	Py_DECREF(ptype);
-	Py_DECREF(pValue);
-#if not(defined(macintosh)) && not(defined(__MACH__) && defined(__APPLE__))
-	Py_Finalize();
-#endif
-	exit(-1);
+	res=-1;
       }
     }
     else{
       char tmpS[1024];
-      sprintf(tmpS, "Cannot find the %s function int the %s file.\n", s->name, tmp->value);
+      sprintf(tmpS, "Cannot find the %s function in the %s file.\n", s->name, tmp->value);
       map* tmps=createMap("text",tmpS);
       printExceptionReportResponse(m,tmps);
-      Py_XDECREF(pFunc);
-      Py_DECREF(pModule);
-      exit(-1);
+      res=-1;
     }
   } else{
@@ -190,9 +175,12 @@
     if (PyErr_Occurred())
       PyErr_Print();
-    exit(-1);
+    PyErr_Clear();
+    res=-1;
+    //exit(-1);
   } 
-#if not(defined(macintosh)) && not(defined(__MACH__) && defined(__APPLE__))
+  PyGILState_Release(gstate);
+  PyEval_AcquireLock();
+  PyThreadState_Swap(mainstate);
   Py_Finalize();
-#endif
   return res;
 }
@@ -202,10 +190,11 @@
   maps* tmp=t;
   while(tmp!=NULL){
-    PyObject* subc=(PyObject*)PyDict_FromMap(tmp->content);
-    if(PyDict_SetItem(res,PyString_FromString(tmp->name),subc)<0){
-      fprintf(stderr,"Unable to parse params...");
-      exit(1);
-    }
-    Py_DECREF(subc);
+    PyObject* value=(PyObject*)PyDict_FromMap(tmp->content);
+    PyObject* name=PyString_FromString(tmp->name);
+    if(PyDict_SetItem(res,name,value)<0){
+      fprintf(stderr,"Unable to set map value ...");
+      return NULL;
+    }
+    Py_DECREF(name);
     tmp=tmp->next;
   }  
@@ -223,18 +212,14 @@
 	PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value));
 	if(PyDict_SetItem(res,name,value)<0){
-	  fprintf(stderr,"Unable to parse params...");
-	  Py_DECREF(value);
-	  exit(1);
+	  fprintf(stderr,"Unable to set key value pair...");
+	  return NULL;
 	}
-	Py_DECREF(value);
       }
       else{
 	PyObject* value=PyString_FromString(tmp->value);
 	if(PyDict_SetItem(res,name,value)<0){
-	  fprintf(stderr,"Unable to parse params...");
-	  Py_DECREF(value);
-	  exit(1);
+	  fprintf(stderr,"Unable to set key value pair...");
+	  return NULL;
 	}
-	Py_DECREF(value);
       }
     }
@@ -242,9 +227,7 @@
       PyObject* value=PyString_FromString(tmp->value);
       if(PyDict_SetItem(res,name,value)<0){
-	fprintf(stderr,"Unable to parse params...");
-	Py_DECREF(value);
-	exit(1);
-      }
-      Py_DECREF(value);
+	fprintf(stderr,"Unable to set key value pair...");
+	return NULL;
+      }
     }
     Py_DECREF(name);
@@ -272,8 +255,8 @@
     cursor=(maps*)malloc(MAPS_SIZE);
     cursor->name=PyString_AsString(key);
-#ifdef DEBUG
-    dumpMap(mapFromPyDict((PyDictObject*)value));
-#endif
     cursor->content=mapFromPyDict((PyDictObject*)value);
+#ifdef DEBUG
+    dumpMap(cursor->content);
+#endif
     cursor->next=NULL;
     if(res==NULL)
@@ -284,6 +267,4 @@
     free(cursor->content);
     free(cursor);
-    Py_DECREF(value);
-    Py_DECREF(key);
 #ifdef DEBUG
     dumpMaps(res);
@@ -291,5 +272,4 @@
 #endif
   }
-  Py_DECREF(list);
   return res;
 }
@@ -330,7 +310,5 @@
 	res=createMap(PyString_AsString(key),PyString_AsString(value));
     }
-    Py_DECREF(key);
-  }
-  Py_DECREF(list);
+  }
   return res;
 }
Index: tags/rel-1.2.0-rc3/zoo-kernel/ulinet.c
===================================================================
--- branches/branch-1.2/zoo-kernel/ulinet.c	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/ulinet.c	(revision 302)
@@ -385,5 +385,5 @@
   jsmsg = JS_ValueToString(context,*arg);
   len = JS_GetStringLength(jsmsg);
-  tmp = JS_GetStringBytes(jsmsg);
+  tmp = JS_EncodeString(context,jsmsg);
   c = (char*)malloc((len+1)*sizeof(char));
   c[len] = '\0';
@@ -435,6 +435,7 @@
 
 JSBool
-JSRequest(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+JSRequest(JSContext *cx, uintN argc, jsval *argv1)
 {
+  jsval *argv = JS_ARGV(cx,argv1);
   HINTERNET hInternet;
   char *url;
@@ -488,5 +489,5 @@
   fprintf(stderr,"content downloaded (%d) (%s) \n",dwRead,tmpValue);
 #endif
-  *rval=STRING_TO_JSVAL(JS_NewString(cx,tmpValue,strlen(tmpValue)));
+  JS_SET_RVAL(cx, argv1,STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpValue,strlen(tmpValue))));
   free(url);
   if(argc>=2)
Index: tags/rel-1.2.0-rc3/zoo-kernel/ulinet.h
===================================================================
--- branches/branch-1.2/zoo-kernel/ulinet.h	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/ulinet.h	(revision 302)
@@ -138,5 +138,5 @@
 
 #ifdef USE_JS
-JSBool JSRequest(JSContext*, JSObject*, uintN, jsval*, jsval*);
+JSBool JSRequest(JSContext*, uintN, jsval*);
 #endif
 
Index: tags/rel-1.2.0-rc3/zoo-kernel/zoo_loader.c
===================================================================
--- branches/branch-1.2/zoo-kernel/zoo_loader.c	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/zoo_loader.c	(revision 302)
@@ -48,23 +48,10 @@
 }
 
+#include "service_internal.h"
+
 xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*);
 int runRequest(map*);
 
 using namespace std;
-
-/* ************************************************************************* */
-
-int errorException(maps *m, const char *message, const char *errorcode) 
-{
-  map* errormap = createMap("text", message);
-  addToMap(errormap,"code", errorcode);
-  printExceptionReportResponse(m,errormap);
-  freeMap(&errormap);
-  free(errormap);
-  return -1;
-}
-
-/* ************************************************************************* */
-
 
 #define TRUE 1
@@ -85,5 +72,5 @@
 #ifdef DEBUG
   fprintf (stderr, "Addr:%s\n", cgiRemoteAddr); 
-  fprintf (stderr, "RequestMethod:%s\n", cgiRequestMethod); 
+  fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,strncasecmp(cgiRequestMethod,"post",4),strncmp(cgiContentType,"text/xml",8)==0 || strncasecmp(cgiRequestMethod,"post",4)==0); 
   fprintf (stderr, "Request: %s\n", cgiQueryString);
 #endif
@@ -93,29 +80,63 @@
   if(strncmp(cgiContentType,"text/xml",8)==0 || 
      strncasecmp(cgiRequestMethod,"post",4)==0){
-    char *buffer=new char[cgiContentLength+1];
-    if(fread(buffer,1,cgiContentLength,cgiIn)){
-      buffer[cgiContentLength]=0;
-      tmpMap=createMap("request",buffer);
+    if(cgiContentLength==NULL){
+       cgiContentLength=0;
+       char *buffer=new char[2];
+       char *res=NULL;
+       int r=0;
+       while(r=fread(buffer,sizeof(char),1,cgiIn)){
+	 cgiContentLength+=r;
+	 if(res==NULL){
+	   res=(char*)malloc(1*sizeof(char));
+	   sprintf(res,"%s",buffer);
+	 }
+	 else{
+	   res=(char*)realloc(res,(cgiContentLength+1)*sizeof(char));
+	   char *tmp=strdup(res);
+	   sprintf(res,"%s%s",tmp,buffer);
+	   free(tmp);
+	 }
+       }
+       if(res==NULL){
+	 return errorException(NULL,"ZOO-Kernel failed to process your request cause the request was emtpty.","InternalError");
+       }else
+	 tmpMap=createMap("request",res);
     }else{
-      char **array, **arrayStep;
-      if (cgiFormEntries(&array) != cgiFormSuccess) {
-	return 1;
-      }
-      arrayStep = array;
-      while (*arrayStep) {
-	char *value=new char[cgiContentLength];
-	cgiFormStringNoNewlines(*arrayStep, value, cgiContentLength);
-	char* tmpValueFinal=(char*) malloc((strlen(*arrayStep)+strlen(value)+1)*sizeof(char));
-	sprintf(tmpValueFinal,"%s=%s",*arrayStep,value);
-	tmpMap=createMap("request",tmpValueFinal);
-	free(tmpValueFinal);
-#ifdef DEBUG
-	fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,value);
-#endif
-	delete[]value;
-	arrayStep++;
-      }
-    }
-    delete[]buffer;
+      char *buffer=new char[cgiContentLength+1];
+      if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)){
+	buffer[cgiContentLength]=0;
+	tmpMap=createMap("request",buffer);
+      }else{
+	buffer[0]=0;
+	char **array, **arrayStep;
+	if (cgiFormEntries(&array) != cgiFormSuccess) {
+	  return 1;
+	}
+	arrayStep = array;
+	while (*arrayStep) {
+	  char *ivalue=new char[cgiContentLength];
+	  cgiFormStringNoNewlines(*arrayStep, ivalue, cgiContentLength);
+	  char* tmpValueFinal=(char*) malloc((strlen(*arrayStep)+strlen(ivalue)+1)*sizeof(char));
+	  sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
+	  if(strlen(buffer)==0){
+	    sprintf(buffer,"%s",tmpValueFinal);
+	  }else{
+	    char *tmp=strdup(buffer);
+	    sprintf(buffer,"%s&%s",tmp,tmpValueFinal);
+	    free(tmp);
+	  }
+	  
+	  sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
+	  free(tmpValueFinal);
+#ifdef DEBUG
+	  fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,ivalue);
+#endif
+	  delete[]ivalue;
+	  arrayStep++;
+	}
+	tmpMap=createMap("request",buffer);
+      }
+      delete[]buffer;
+    }
   }
   else{
@@ -162,4 +183,28 @@
       xmlInitParser();
       xmlDocPtr doc = xmlParseMemory(t1->value,cgiContentLength);
+
+
+      {
+	xmlXPathObjectPtr reqptr=extractFromDoc(doc,"/*[local-name()='Envelope']/*[local-name()='Body']/*");
+	if(reqptr!=NULL){
+	  xmlNodeSet* req=reqptr->nodesetval;
+	  if(req!=NULL && req->nodeNr==1){
+	    addToMap(tmpMap,"soap","true");
+	    int k=0;
+	    for(k;k < req->nodeNr;k++){
+	      xmlNsPtr ns=xmlNewNs(req->nodeTab[k],BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
+	      xmlDocSetRootElement(doc, req->nodeTab[k]);
+	      xmlChar *xmlbuff;
+	      int buffersize;
+	      xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, "utf-8", 1);
+	      addToMap(tmpMap,"xrequest",(char*)xmlbuff);
+	      char *tmp=(char*)xmlbuff;
+	      fprintf(stderr,"%s\n",tmp);
+	      xmlFree(xmlbuff);
+	    }
+	  }
+	}
+      }
+
       xmlNodePtr cur = xmlDocGetRootElement(doc);
       char *tval;
@@ -172,11 +217,7 @@
       if(tval!=NULL)
 	addToMap(tmpMap,"language",tval);
-      
-      const char* requests[3];
-      requests[0]="GetCapabilities";
-      requests[1]="DescribeProcess";
-      requests[2]="Execute";
+      const char* requests[3]={"GetCapabilities","DescribeProcess","Execute"};
       for(int j=0;j<3;j++){
-	char tt[35];
+	char tt[128];
 	sprintf(tt,"/*[local-name()='%s']",requests[j]);
 	xmlXPathObjectPtr reqptr=extractFromDoc(doc,tt);
Index: tags/rel-1.2.0-rc3/zoo-kernel/zoo_service_loader.c
===================================================================
--- branches/branch-1.2/zoo-kernel/zoo_service_loader.c	(revision 268)
+++ tags/rel-1.2.0-rc3/zoo-kernel/zoo_service_loader.c	(revision 302)
@@ -452,16 +452,6 @@
   _getcwd(ntmp,1024);
 #endif
-  r_inputs=getMap(request_inputs,"metapath");
-  if(r_inputs==NULL){
-    if(request_inputs==NULL)
-      request_inputs=createMap("metapath","");
-    else
-      addToMap(request_inputs,"metapath","");
-#ifdef DEBUG
-    fprintf(stderr,"ADD METAPATH\n");
-    dumpMap(request_inputs);
-#endif
-    r_inputs=getMap(request_inputs,"metapath");
-  }
+  r_inputs=getMapOrFill(request_inputs,"metapath","");
+
   char conf_file[10240];
   snprintf(conf_file,10240,"%s/%s/main.cfg",ntmp,r_inputs->value);
@@ -493,4 +483,9 @@
   textdomain("zoo-services");
 
+  map* lsoap=getMap(request_inputs,"soap");
+  if(lsoap!=NULL && strcasecmp(lsoap->value,"true")==0)
+    setMapInMaps(m,"main","isSoap","true");
+  else
+    setMapInMaps(m,"main","isSoap","false");
 
   /**
@@ -1013,5 +1008,4 @@
 	    lmap->value=strdup(tmpValue);
 	    free(tmpValue);
-	    dumpMap(tmpmaps->content);
 	    tmpc=strtok(NULL,"@");
 	    continue;
@@ -1042,39 +1036,17 @@
 	      fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
 #endif
+	      char *tmpx=url_encode(tmpv1+1);
+	      addToMap(tmpmaps->content,tmpn1,tmpx);
+	      
 #ifndef WIN32
 	      if(CHECK_INET_HANDLE(hInternet))
 #endif
 		{
-		  res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,
-				      INTERNET_FLAG_NO_CACHE_WRITE,0);
-#ifdef DEBUG
-		  fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",
-			  tmpv1+1,res.nDataAlloc,res.nDataLen);
-#endif
-		  char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
-		  if(tmpContent == NULL){
-		    return errorException(m, _("Unable to allocate memory."), "InternalError");
-		  }
-		  size_t dwRead;
-		  InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);
-		  map* tmpMap=getMap(tmpmaps->content,"value");
-		  if(tmpMap!=NULL){
-		    free(tmpMap->value);
-		    tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));
-		    memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));
-		    tmpMap->value[res.nDataLen]=0;
-		    if(strlen(tmpContent)!=res.nDataLen){
-		      char tmp[256];
-		      sprintf(tmp,"%d",res.nDataLen*sizeof(char));
-		      addToMap(tmpmaps->content,"size",tmp);
-		    }
-		  }
-		  free(tmpContent);
+		  loadRemoteFile(m,tmpmaps->content,hInternet,tmpv1+1);
 		}
-	      char *tmpx=url_encode(tmpv1+1);
-	      addToMap(tmpmaps->content,tmpn1,tmpx);
-	      free(tmpx);
+	      char *tmpx1=url_encode(tmpv1+1);
+	      addToMap(tmpmaps->content,tmpn1,tmpx1);
+	      free(tmpx1);
 	      addToMap(tmpmaps->content,"Reference",tmpv1+1);
-	      dumpMap(tmpmaps->content);
 	    }
 	  tmpc=strtok(NULL,"@");
@@ -1193,10 +1165,5 @@
 	    fprintf(stderr,"REFERENCE\n");
 #endif
-	    const char *refs[5];
-	    refs[0]="mimeType";
-	    refs[1]="encoding";
-	    refs[2]="schema";
-	    refs[3]="method";
-	    refs[4]="href";
+	    const char *refs[5]={"mimeType","encoding","schema","method","href"};
 	    for(int l=0;l<5;l++){
 #ifdef DEBUG
@@ -1213,16 +1180,5 @@
 		  if(!(ltmp!=NULL && strcmp(ltmp->value,"POST")==0)
 		     && CHECK_INET_HANDLE(hInternet)){
-		    res=InternetOpenUrl(hInternet,(char*)val,NULL,0,
-					INTERNET_FLAG_NO_CACHE_WRITE,0);
-		    char* tmpContent=
-		      (char*)calloc((res.nDataLen+1),sizeof(char));
-		    if(tmpContent == NULL){
-		      return errorException(m, _("Unable to allocate memory."), "InternalError");
-		    }
-		    size_t dwRead;
-		    InternetReadFile(res, (LPVOID)tmpContent,
-				     res.nDataLen, &dwRead);
-		    tmpContent[res.nDataLen]=0;
-		    addToMap(tmpmaps->content,"value",tmpContent);
+		    loadRemoteFile(m,tmpmaps->content,hInternet,(char*)val);
 		  }
 		}
@@ -1415,10 +1371,10 @@
 		    else
 		      tmpmaps->content=createMap(list[l],(char*)val);
+#ifdef DEBUG
+		    fprintf(stderr,"%s\n",val);
+#endif
 		  }
-#ifdef DEBUG
-		  fprintf(stderr,"%s\n",val);
-#endif
 		  xmlFree(val);
-		  free(list[l]);
+		  free(list[l]);		  
 		}
 	      }
@@ -1428,11 +1384,8 @@
 		 * mimeType, encoding, schema
 		 */
-		const char *coms[3];
-		coms[0]="mimeType";
-		coms[1]="encoding";
-		coms[2]="schema";
+		const char *coms[3]={"mimeType","encoding","schema"};
 		for(int l=0;l<3;l++){
 #ifdef DEBUG
-		  fprintf(stderr,"*** ComplexData %s ***",coms[l]);
+		  fprintf(stderr,"*** ComplexData %s ***\n",coms[l]);
 #endif
 		  xmlChar *val=xmlGetProp(cur4,BAD_CAST coms[l]);
@@ -1442,18 +1395,33 @@
 		    else
 		      tmpmaps->content=createMap(coms[l],(char*)val);
+#ifdef DEBUG
+		    fprintf(stderr,"%s\n",val);
+#endif
 		  }
-#ifdef DEBUG
-		  fprintf(stderr,"%s\n",val);
-#endif
 		  xmlFree(val);
 		}
 	      }
+
 	      map* test=getMap(tmpmaps->content,"encoding");
-	      if(test==NULL || strcasecmp(test->value,"base64")!=0){
+	      if(test==NULL){
+		if(tmpmaps->content!=NULL)
+		  addToMap(tmpmaps->content,"encoding","utf-8");
+		else
+		  tmpmaps->content=createMap("encoding","utf-8");
+		test=getMap(tmpmaps->content,"encoding");
+	      }
+
+	      if(strcasecmp(test->value,"base64")!=0){
 		xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1);
-		if(mv==NULL){
+		map* ltmp=getMap(tmpmaps->content,"mimeType");
+		if(mv==NULL || 
+		   (xmlStrcasecmp(cur4->name, BAD_CAST "ComplexData")==0 &&
+		    (ltmp==NULL || strncasecmp(ltmp->value,"text/xml",8)==0) )){
 		  xmlDocPtr doc1=xmlNewDoc(BAD_CAST "1.0");
 		  int buffersize;
-		  xmlDocSetRootElement(doc1,cur4->xmlChildrenNode);
+		  xmlNodePtr cur5=cur4->children;
+		  while(cur5!=NULL &&cur5->type!=XML_ELEMENT_NODE)
+		    cur5=cur5->next;
+		  xmlDocSetRootElement(doc1,cur5);
 		  xmlDocDumpFormatMemoryEnc(doc1, &mv, &buffersize, "utf-8", 1);
 		  char size[1024];
@@ -1556,8 +1524,5 @@
 	 * storeExecuteResponse, lineage, status
 	 */
-	const char *ress[3];
-	ress[0]="storeExecuteResponse";
-	ress[1]="lineage";
-	ress[2]="status";
+	const char *ress[3]={"storeExecuteResponse","lineage","status"};
 	xmlChar *val;
 	for(int l=0;l<3;l++){
@@ -1580,15 +1545,55 @@
 	xmlNodePtr cur1=cur->children;
 	while(cur1){
-	  if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){
+	  /**
+	   * Indentifier
+	   */
+	  if(xmlStrncasecmp(cur1->name,BAD_CAST "Identifier",xmlStrlen(cur1->name))==0){
+	    xmlChar *val=
+	      xmlNodeListGetString(doc,cur1->xmlChildrenNode,1);
+	    if(tmpmaps==NULL){
+	      tmpmaps=(maps*)calloc(1,MAPS_SIZE);
+	      if(tmpmaps == NULL){
+		return errorException(m, _("Unable to allocate memory."), "InternalError");
+	      }
+	      tmpmaps->name=strdup((char*)val);
+	      tmpmaps->content=NULL;
+	      tmpmaps->next=NULL;
+	    }
+	    else
+	      tmpmaps->name=strdup((char*)val);;
+	    xmlFree(val);
+	  }
+	  /**
+	   * Title, Asbtract
+	   */
+	  else if(xmlStrncasecmp(cur1->name,BAD_CAST "Title",xmlStrlen(cur1->name))==0 ||
+		  xmlStrncasecmp(cur1->name,BAD_CAST "Abstract",xmlStrlen(cur1->name))==0){
+	    xmlChar *val=
+	      xmlNodeListGetString(doc,cur1->xmlChildrenNode,1);
+	    if(tmpmaps==NULL){
+	      tmpmaps=(maps*)calloc(1,MAPS_SIZE);
+	      if(tmpmaps == NULL){
+		return errorException(m, _("Unable to allocate memory."), "InternalError");
+	      }
+	      tmpmaps->name=strdup("missingIndetifier");
+	      tmpmaps->content=createMap((char*)cur1->name,(char*)val);
+	      tmpmaps->next=NULL;
+	    }
+	    else{
+	      if(tmpmaps->content!=NULL)
+		addToMap(tmpmaps->content,
+			 (char*)cur1->name,(char*)val);
+	      else
+		tmpmaps->content=
+		  createMap((char*)cur1->name,(char*)val);
+	    }
+	    xmlFree(val);
+	  }
+	  else if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){
 	    /**
 	     * Get every attribute from a Output node
 	     * mimeType, encoding, schema, uom, asReference
 	     */
-	    const char *outs[5];
-	    outs[0]="mimeType";
-	    outs[1]="encoding";
-	    outs[2]="schema";
-	    outs[3]="uom";
-	    outs[4]="asReference";
+	    const char *outs[5]={"mimeType","encoding","schema","uom","asReference"};
 	    for(int l=0;l<5;l++){
 #ifdef DEBUG
@@ -1632,5 +1637,5 @@
 	       * Title, Asbtract
 	       */
-	      if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 ||
+	      else if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 ||
 		 xmlStrncasecmp(cur2->name,BAD_CAST "Abstract",xmlStrlen(cur2->name))==0){
 		xmlChar *val=
@@ -1684,4 +1689,5 @@
   dumpMaps(request_output_real_format);
   dumpMap(request_inputs);
+  fprintf(stderr,"\n%i\n",i);
 #endif
 
@@ -1691,7 +1697,13 @@
    */
   char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,0);
-  if(strcmp(dfv,"")!=0){
+  char *dfv1=addDefaultValues(&request_output_real_format,s1->outputs,m,1);
+  if(strcmp(dfv1,"")!=0 || strcmp(dfv,"")!=0){
     char tmps[1024];
-    snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv);
+    if(strcmp(dfv,"")!=0){
+      snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv);
+    }
+    else if(strcmp(dfv1,"")!=0){
+      snprintf(tmps,1024,_("The <%s> argument was specified as Output identifier but not defined in the ZOO Configuration File. Please, correct your query or the ZOO Configuration File."),dfv1);
+    }
     map* tmpe=createMap("text",tmps);
     addToMap(tmpe,"code","MissingParameterValue");
@@ -1713,5 +1725,4 @@
     return 1;
   }
-  addDefaultValues(&request_output_real_format,s1->outputs,m,1);
 
   ensureDecodedBase64(&request_input_real_format);
@@ -1807,4 +1818,9 @@
   addToMap(_tmpMaps->content,"status","0");
   addToMap(_tmpMaps->content,"cwd",ntmp);
+  map* ltmp=getMap(request_inputs,"soap");
+  if(ltmp!=NULL)
+    addToMap(_tmpMaps->content,"soap",ltmp->value);
+  else
+    addToMap(_tmpMaps->content,"soap","false");
   if(cgiCookie!=NULL && strlen(cgiCookie)>0){
     addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1);
@@ -1824,5 +1840,4 @@
     if(istat==0 && file_status.st_size>0){
       conf_read(session_file_path,tmpSess);
-      dumpMaps(tmpSess);
       addMapsToMaps(&m,tmpSess);
       freeMaps(&tmpSess);
@@ -1849,5 +1864,4 @@
     addToMap(request_inputs,"status","true");
     status=getMap(request_inputs,"status");
-    dumpMap(request_inputs);
     fprintf(stderr,"cgiSID : %s",cgiSid);
   }
