Index: /trunk/zoo-kernel/configure.ac
===================================================================
--- /trunk/zoo-kernel/configure.ac	(revision 56)
+++ /trunk/zoo-kernel/configure.ac	(revision 57)
@@ -288,8 +288,8 @@
 	if test -d "$JDKHOME/jre/lib/i386";
 	then
-		JAVA_LDFLAGS="-L$JDKHOME/jre/lib/i386/server/ -ljvm -lpthread"
+		JAVA_LDFLAGS="-L$JDKHOME/jre/lib/i386/client/ -ljvm -lpthread"
 		JAVA_CPPFLAGS="-I$JDKHOME/include -I$JDKHOME/include/linux"
 	else
-		JAVA_LDFLAGS="-L$JDKHOME/jre/lib/amd64/server/ -ljvm -lpthread"
+		JAVA_LDFLAGS="-L$JDKHOME/jre/lib/amd64/client/ -ljvm -lpthread"
                 JAVA_CPPFLAGS="-I$JDKHOME/include -I$JDKHOME/include/linux"
 	fi
Index: /trunk/zoo-kernel/service.h
===================================================================
--- /trunk/zoo-kernel/service.h	(revision 56)
+++ /trunk/zoo-kernel/service.h	(revision 57)
@@ -133,5 +133,5 @@
     map* tmp=m;
     while(tmp!=NULL){
-      if(strlen(tmp->name)==strlen(key) && strncasecmp(tmp->name,key,strlen(key))==0)
+      if(strcasecmp(tmp->name,key)==0)
 	return true;
       tmp=tmp->next;
@@ -146,5 +146,5 @@
     maps* tmp=m;
     while(tmp!=NULL){
-      if(strlen(tmp->name)==strlen(key) && strncasecmp(tmp->name,key,strlen(key))==0){
+      if(strcasecmp(tmp->name,key)==0){
 	return tmp;
       }
@@ -157,5 +157,5 @@
     map* tmp=m;
     while(tmp!=NULL){
-      if(strlen(tmp->name)==strlen(key) && strncasecmp(tmp->name,key,strlen(key))==0){
+      if(strcasecmp(tmp->name,key)==0){
 	return tmp;
       }
@@ -239,5 +239,5 @@
     elements* tmp=e;
     while(tmp!=NULL){
-      if(strlen(tmp->name)==strlen(key) && strncasecmp(key,tmp->name,strlen(key))==0)
+      if(strcasecmp(key,tmp->name)==0)
 	return true;
       tmp=tmp->next;
@@ -249,5 +249,5 @@
     elements* tmp=m;
     while(tmp!=NULL){
-      if(strlen(tmp->name)==strlen(key) && strncasecmp(tmp->name,key,strlen(tmp->name))==0)
+      if(strcasecmp(tmp->name,key)==0)
 	return tmp;
       tmp=tmp->next;
@@ -260,10 +260,10 @@
     iotype* _cursor=*i;
     if(_cursor!=NULL){
-      freeMap(&_cursor->content);
-      free(_cursor->content);
       if(_cursor->next!=NULL){
 	freeIOType(&_cursor->next);
 	free(_cursor->next);
       }
+      freeMap(&_cursor->content);
+      free(_cursor->content);
     }
   }
@@ -272,16 +272,21 @@
     elements* tmp=*e;
     if(tmp!=NULL){
-      free(tmp->name);
+      if(tmp->name!=NULL)
+	free(tmp->name);
       freeMap(&tmp->content);
-      free(tmp->content);
+      if(tmp->content!=NULL)
+	free(tmp->content);
       freeMap(&tmp->metadata);
-      free(tmp->metadata);
-      free(tmp->format);
+      if(tmp->metadata!=NULL)
+	free(tmp->metadata);
+      if(tmp->format!=NULL)
+	free(tmp->format);
       freeIOType(&tmp->defaults);
       if(tmp->defaults!=NULL)
 	free(tmp->defaults);
       freeIOType(&tmp->supported);
-      if(tmp->supported!=NULL)
+      if(tmp->supported!=NULL){
 	free(tmp->supported);
+      }
       freeElements(&tmp->next);
     }
@@ -361,34 +366,46 @@
   static void addMapToIoType(iotype** io,map* mi){
     iotype* tmp=*io;
-    while(tmp!=NULL){
-#ifdef DEBUG
-      fprintf(stderr,">> CURRENT MAP");
-      dumpMap(tmp->content);
-#endif
-      tmp=tmp->next;
-    }
-#ifdef DEBUG
-    fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
-    fflush(stderr);
-#endif
-    tmp=(iotype*)malloc(IOTYPE_SIZE);
-#ifdef DEBUG
-    fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
-    fflush(stderr);
-#endif
-    tmp->content=NULL;
-#ifdef DEBUG
-    fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
-    fflush(stderr);
-#endif
-    addMapToMap(&tmp->content,mi);
-#ifdef DEBUG
-    fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
-    fflush(stderr);
-#endif
-    dumpMap(tmp->content);
-    tmp->next=NULL;
-  }
-
+    while(tmp->next!=NULL){
+      tmp=tmp->next;
+    }
+    tmp->next=(iotype*)malloc(IOTYPE_SIZE);
+    tmp->next->content=NULL;
+    addMapToMap(&tmp->next->content,mi);
+    tmp->next->next=NULL;
+  }
+
+  static bool contains(map* m,map* i){
+    while(i!=NULL){      
+      if(strcasecmp(i->name,"value")!=0 &&
+	 strcasecmp(i->name,"xlink:href")!=0){
+	map *tmp;
+	if(hasKey(m,i->name) && (tmp=getMap(m,i->name))!=NULL && 
+	   strcasecmp(i->value,tmp->value)!=0)
+	  return false;
+      }
+      i=i->next;
+    }
+    return true;
+  }
+
+  static iotype* getIoTypeFromElement(elements* e,char *name, map* values){
+    elements* cursor=e;
+    while(cursor!=NULL){
+      if(strcasecmp(cursor->name,name)==0){
+	if(contains(cursor->defaults->content,values)==true)
+	  return cursor->defaults;
+	else{
+	  iotype* tmp=cursor->supported;
+	  while(tmp!=NULL){
+	    if(contains(tmp->content,values)==true)
+	      return tmp;	    
+	    tmp=tmp->next;
+	  }
+	}
+      }
+      cursor=cursor->next;
+    }
+    return NULL;
+  }
 
   static maps* dupMaps(maps** mo){
@@ -434,5 +451,4 @@
 	free(_ztmpm->value);
 	_ztmpm->value=strdup(value);
-	dumpMap(_ztmpm);
       }else{
 	addToMap(_tmpm->content,subkey,value);
@@ -502,13 +518,9 @@
 	tmp->supported=(iotype*)malloc(IOTYPE_SIZE);
 	tmp->supported->content=NULL;
+	addMapToMap(&tmp->supported->content,e->supported->content);
 	tmp->supported->next=NULL;
-	addMapToMap(&tmp->supported->content,e->supported->content);
-	iotype *etmp=*(&tmp->supported->next) ;
 	iotype *tmp2=e->supported->next;
 	while(tmp2!=NULL){
-	  etmp=(iotype*)malloc(IOTYPE_SIZE);
-	  etmp->content=NULL;
-	  addMapToMap(&etmp->content,tmp2->content);
-	  etmp->next=NULL;
+	  addMapToIoType(&tmp->supported,tmp2->content);
 #ifdef DEBUG
 	  fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
@@ -516,5 +528,4 @@
 #endif
 	  tmp2=tmp2->next;
-	  etmp=etmp->next;
 	}
       }
@@ -532,7 +543,5 @@
       *m=dupElements(tmp);
     }else{
-      while(_cursor->next!=NULL)
-	_cursor=_cursor->next;
-      _cursor->next=dupElements(tmp);
+      addToElements(&(*m)->next,tmp);
     }
   }
Index: /trunk/zoo-kernel/service_conf.l
===================================================================
--- /trunk/zoo-kernel/service_conf.l	(revision 56)
+++ /trunk/zoo-kernel/service_conf.l	(revision 57)
@@ -109,5 +109,5 @@
 
 
-<DANSBALISE>{Name}			{srlval.chaine=strdup(yytext);return ID;}
+<DANSBALISE>{Name}{newline}*			{memmove(srlval.chaine,yytext,(strlen(yytext)+1)*sizeof(char));return ID;}
 
 
Index: /trunk/zoo-kernel/service_conf.y
===================================================================
--- /trunk/zoo-kernel/service_conf.y	(revision 56)
+++ /trunk/zoo-kernel/service_conf.y	(revision 57)
@@ -133,5 +133,4 @@
  : STag contentetoile ETag	
 {
-  free($3);
 }
 
@@ -210,6 +209,7 @@
 	  my_service->inputs->next=NULL;
 	}
-	else
+	else if(current_element!=NULL && current_element->name!=NULL){
 	  addToElements(&my_service->inputs,current_element);
+	}
 #ifdef DEBUG_SERVICE_CONF
 	fprintf(stderr,"CURRENT_ELEMENT\n");
@@ -267,5 +267,5 @@
 	      addMapToMap(&current_element->metadata,current_content);
 	      current_element->next=NULL;
-	      current_element->format=$2;
+	      current_element->format=strdup($2);
 	      current_element->defaults=NULL;
 	      current_element->supported=NULL;
@@ -280,5 +280,5 @@
 	    current_element->metadata=NULL;
 	    current_element->next=NULL;
-	    current_element->format=$2;
+	    current_element->format=strdup($2);
 	    current_element->defaults=NULL;
 	    current_element->supported=NULL;
@@ -297,6 +297,6 @@
 	      if(wait_defaults==true){
 		defaultsc++;
-		freeMap(&current_content);
-		current_content=NULL;
+		/*freeMap(&current_content);
+		  current_content=NULL;*/
 	      }
 	      current_data=5;
@@ -305,7 +305,4 @@
   printf("* Identifiant : %s\n",$2);
 #endif
-  /* et on renvoie l'identifiant de balise afin de pouvoir le comparer */
-  /* avec la balise jumelle fermante ! */
-  $$ = $2 ;
 }
  ;
@@ -338,5 +335,4 @@
   printf ("attribute : %s\n",$1) ;
 #endif
-  free($1);
 }
  ;
@@ -391,44 +387,32 @@
     current_content=NULL;
     current_element->supported=NULL;
+    current_element->next=NULL;
   }
   if(strcmp($3,"Supported")==0){
     current_data=previous_data;
     if(current_element->supported==NULL){
-      //addMapToIoType(&current_element->supported,current_content);
-      current_element->supported=(iotype*)malloc(IOTYPE_SIZE);
-      current_element->supported->content=NULL;
-      addMapToMap(&current_element->supported->content,current_content);
-      freeMap(&current_content);
-      free(current_content);
-      current_element->supported->next=NULL;
-      current_content=NULL;
+      if(current_content!=NULL){
+	current_element->supported=(iotype*)malloc(IOTYPE_SIZE);
+	current_element->supported->content=NULL;
+	addMapToMap(&current_element->supported->content,current_content);
+	freeMap(&current_content);
+	free(current_content);
+	current_element->supported->next=NULL;
+	current_content=NULL;
+      }else{
+	current_element->supported=NULL;
+	current_element->next=NULL;
+      }
     }
     else{
-#ifdef DEBUG
-      // Currently we support only one supported format
+#ifdef DEBUG_SERVICE_CONF
       fprintf(stderr,"SECOND SUPPORTED FORMAT !!!!\n");
 #endif
-      //addMapToIoType(&current_element->supported,current_content);
-      /*iotype* iotmp=*(&current_element->supported);
-      while(iotmp!=NULL){
-	dumpMap(iotmp->content);
-	iotmp=iotmp->next;
-      }
-      iotmp=(iotype*)malloc(IOTYPE_SIZE);
-      iotmp->content=NULL;
-      addMapToMap(&iotmp->content,current_content);
-      iotmp->next=NULL;
-      dumpElements(current_element);
-      fprintf(stderr,"SECOND SUPPORTED FORMAT MAP START !!!!\n");
-      dumpMap(current_content);
-      fprintf(stderr,"SECOND SUPPORTED FORMAT MAP END !!!!\n");*/
+      addMapToIoType(&current_element->supported,current_content);
       freeMap(&current_content);
       free(current_content);
       current_content=NULL;
-      /*freeMap(&iotmp->content);
-      free(&iotmp->content);
-      free(iotype);*/
-#ifdef DEBUG
-      // Currently we support only one supported format
+#ifdef DEBUG_SERVICE_CONF
+      dumpElements(current_element);
       fprintf(stderr,"SECOND SUPPORTED FORMAT !!!!\n");
 #endif
@@ -436,7 +420,4 @@
     current_content=NULL;
   }
-  /* on renvoie l'identifiant de la balise pour pouvoir comparer les 2 */
-  /* /!\ une balise fermante n'a pas d'attributs (c.f. : W3C) */
-  $$ = $3;
 }
  ;
@@ -610,6 +591,5 @@
       if(current_data==2){ 
 	if(wait_inputs==true){
-	  fprintf(stderr,"dup INPUTS\n");
-	  if(current_element->name!=NULL){
+	  if(current_element!=NULL && current_element->name!=NULL){
 	    if(my_service->inputs==NULL){
 	      my_service->inputs=dupElements(current_element);
@@ -661,5 +641,4 @@
 	  }
 	  wait_inputs=false;
-	  dumpMap(current_content);
 	  current_content=NULL;
 	}
@@ -755,5 +734,5 @@
   int resultatYYParse = srparse() ;
   
-  if(wait_outputs==true && current_element->name!=NULL){
+  if(wait_outputs==true && current_element!=NULL && current_element->name!=NULL){
     if(my_service->outputs==NULL){      
 #ifdef DEBUG_SERVICE_CONF
@@ -762,7 +741,4 @@
       my_service->outputs=dupElements(current_element);
       my_service->outputs->next=NULL;
-      freeElements(&current_element);
-      free(current_element);
-      current_element=NULL;
     }
     else{
@@ -778,8 +754,10 @@
     free(current_element);
     current_element=NULL;
+#ifdef DEBUG_SERVICE_CONF
+    fprintf(stderr,"(DATAOUTPUTS - 631) FREE current_element\n");
+#endif
   }
   if(current_element!=NULL){
     freeElements(&current_element);
-    fprintf(stderr,"LINE 709");
     free(current_element);
     current_element=NULL;
@@ -787,5 +765,4 @@
   if(current_content!=NULL){
     freeMap(&current_content);
-    fprintf(stderr,"LINE 715");
     free(current_content);
     current_content=NULL;
Index: /trunk/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-kernel/service_internal.c	(revision 56)
+++ /trunk/zoo-kernel/service_internal.c	(revision 57)
@@ -309,9 +309,8 @@
     map* tmp2=tmp4->content;
     while(tmp2!=NULL){
-      if(strncasecmp(tmp2->name,"keywords",8)!=0 &&
-	 strncasecmp(tmp2->name,"serverAddress",13)!=0 &&
-	 strncasecmp(tmp2->name,"lang",4)!=0 &&
-	 strncasecmp(tmp2->name,"encoding",8)!=0 &&
-	 strncasecmp(tmp2->name,"version",7)!=0){
+      if(strcasecmp(tmp2->name,"abstract")==0 ||
+	 strcasecmp(tmp2->name,"title")==0 ||
+	 strcasecmp(tmp2->name,"accessConstraints")==0 ||
+	 strcasecmp(tmp2->name,"fess")==0){
 	tmp2->name[0]=toupper(tmp2->name[0]);
 	nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name);
@@ -370,4 +369,14 @@
   if(tmp4!=NULL){
     map* tmp2=tmp4->content;
+    char *tmpAddress[6];
+    tmpAddress[0]="addressDeliveryPoint";
+    tmpAddress[1]="addressCity";
+    tmpAddress[2]="addressAdministrativeArea";
+    tmpAddress[3]="addressPostalCode";
+    tmpAddress[4]="addressCountry";
+    tmpAddress[5]="addressElectronicMailAddress";
+    char *tmpPhone[2];
+    tmpPhone[0]="phoneVoice";
+    tmpPhone[1]="phoneFacsimile";
     while(tmp2!=NULL){
       if(strcmp(tmp2->name,"keywords")!=0 &&
@@ -395,19 +404,27 @@
 	    else 
 	      if(strncmp(tmp2->name,"Phone",5)==0){
-		char *toto=NULL;
-		char *toto1=tmp2->name;
-		toto=strstr(toto1,"Phone");
-		nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5);
-		xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
-		xmlAddChild(nc5,nc1);
+		int j;
+		for(j=0;j<2;j++)
+		  if(strlen(tmp2->name)==strlen(tmpPhone[j]) && strncasecmp(tmp2->name,tmpPhone[j],strlen(tmp2->name))==0){
+		    char *toto=NULL;
+		    char *toto1=tmp2->name;
+		    toto=strstr(toto1,"Phone");
+		    nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5);
+		    xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
+		    xmlAddChild(nc5,nc1);
+		  }
 	      }
 	      else 
 		if(strncmp(tmp2->name,"Address",7)==0){
-		  char *toto=NULL;
-		  char *toto1=tmp2->name;
-		  toto=strstr(toto1,"Address");
-		  nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7);
-		  xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
-		  xmlAddChild(nc6,nc1);
+		  int j;
+		  for(j=0;j<6;j++)
+		    if(strlen(tmp2->name)==strlen(tmpAddress[j]) && strncasecmp(tmp2->name,tmpAddress[j],strlen(tmp2->name))==0){
+		      char *toto=NULL;
+		      char *toto1=tmp2->name;
+		      toto=strstr(toto1,"Address");
+		      nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7);
+		      xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
+		      xmlAddChild(nc6,nc1);
+		    }
 		}
 	}
@@ -1084,5 +1101,5 @@
     te=getMapFromMaps(m,"lenv","message");
     if(te!=NULL)
-      addToMap(errorMap,"text",te->value);
+      addToMap(errorMap,"text",_ss(te->value));
     else
       addToMap(errorMap,"text",_("No more information available"));
@@ -1364,5 +1381,4 @@
     if(tmp1!=NULL){
       nc2 = xmlNewNode(ns_ows, BAD_CAST tmp2[j]);
-      fprintf(stderr,"[%s] \n[%s]\n",tmp1->value,_ss(tmp1->value));
       xmlAddChild(nc2,xmlNewText(BAD_CAST _ss(tmp1->value)));
       xmlAddChild(root,nc2);
@@ -1398,5 +1414,4 @@
 
 void printExceptionReportResponse(maps* m,map* s){
-  
   int buffersize;
   xmlDocPtr doc;
@@ -1425,4 +1440,5 @@
   xmlFree(xmlbuff);
   xmlCleanupParser();
+  zooXmlCleanupNs();
 }
 
@@ -1436,5 +1452,6 @@
   maps* tmpMap=getMaps(m,"main");
 
-  ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
+  int nsid=zooXmlAddNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
+  ns=usedNs[nsid];
   n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
 
@@ -1493,21 +1510,41 @@
     if(toto!=NULL && strcasecmp(toto->value,"true")==0){
       toto=getMap(request_outputs->content,"extension");
-      /* put gml extension if the extension is defined as .js and the result will be a gml file */
-      map* mtype=getMap(request_outputs->content,"mimeType");
-      if (strcasecmp(toto->value,"js")==0 && strcasecmp(mtype->value,"text/xml")==0) {
-	toto->value="gml";
-      }
       map *tmp1=getMapFromMaps(m,"main","tmpPath");
-      char *file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
+      char *file_name;
+      bool hasExt=true;
+      if(toto==NULL){
+	// We can fallback to a default list of supported formats using
+	// mimeType information if present here. Maybe we can add more formats
+	// here.
+	// If mimeType was not found, we then set txt as the default extension.
+	map* mtype=getMap(request_outputs->content,"mimeType");
+	if(mtype!=NULL){
+	  if(strcasecmp(mtype->value,"text/xml")==0)
+	    toto=createMap("extension","xml");
+	  else
+	    toto=createMap("extension","txt");
+	}
+	if(toto==NULL)
+	  toto=createMap("extension","txt");
+	hasExt=false;
+      }
+      file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
       sprintf(file_name,"%s/%s_%i.%s",tmp1->value,s->name,cpid+100000,toto->value);
       FILE *ofile=fopen(file_name,"w");
+      if(ofile==NULL)
+	fprintf(stderr,"Unable to create file on disk implying segfault ! \n");
       map *tmp2=getMapFromMaps(m,"main","tmpUrl");
       map *tmp3=getMapFromMaps(m,"main","serverAddress");
-      char *file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
+      char *file_url;
+      file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
       sprintf(file_url,"%s/%s/%s_%i.%s",tmp3->value,tmp2->value,s->name,cpid+100000,toto->value);
       addToMap(request_outputs->content,"Reference",file_url);
+      if(hasExt!=true){
+	freeMap(&toto);
+	free(toto);
+      }
       toto=getMap(request_outputs->content,"value");
-      if(toto!=NULL)
-	fwrite(toto->value,sizeof(char),strlen(toto->value),ofile);
+      if(toto!=NULL && toto->value!=NULL)
+	fwrite(toto->value,1,(strlen(toto->value)+1)*sizeof(char),ofile);
       fclose(ofile);
       free(file_name);
@@ -1601,5 +1638,4 @@
   BIO_free_all(b64);
 
-  fprintf(stderr,"BASE64 [%s] \n",buff);
   return buff;
 }
@@ -1610,4 +1646,8 @@
   while(tmpInputs!=NULL){
     maps *tmpMaps=getMaps(out1,tmpInputs->name);
+    /*fprintf(stderr,"IN LOOP\n");
+    dumpElements(tmpInputs);
+    dumpMaps(tmpMaps);
+    fprintf(stderr,"/ IN LOOP\n");*/
     if(tmpMaps==NULL){
       map* tmpMap1=getMap(tmpInputs->content,"minOccurs");
@@ -1617,5 +1657,5 @@
 	}
       maps* tmpMaps2=(maps*)malloc(MAPS_SIZE);
-      tmpMaps2->name=strdup((char*)tmpInputs->name);
+      tmpMaps2->name=strdup(tmpInputs->name);
       tmpMaps2->content=NULL;
       tmpMaps2->next=NULL;
@@ -1625,7 +1665,9 @@
 	tmpIoType=tmpIoType->next;
       }
-      map *tmpMap=getMap(tmpMaps2->content,"value");
-      if(tmpMap==NULL)
-	addToMap(tmpMaps2->content,"value","NULL");
+      if(strncmp(type,"outputs",7)==0){
+	map *tmpMap=getMap(tmpMaps2->content,"value");
+	if(tmpMap==NULL)
+	  addToMap(tmpMaps2->content,"value","NULL");
+      }
       if(out1==NULL){
 	*out=dupMaps(&tmpMaps2);
@@ -1638,19 +1680,22 @@
     }
     else{
-      map* tmpContent=tmpInputs->defaults->content;
-      
-      map* cval=NULL;
-      
-      while(tmpContent!=NULL){
-	if((cval=getMap(tmpMaps->content,tmpContent->name))==NULL){
-#ifdef DEBUG
-	  fprintf(stderr,"addDefaultValues %s => %s\n",tmpContent->name,tmpContent->value);
-#endif
-	  if(tmpMaps->content==NULL)
-	    tmpMaps->content=createMap(tmpContent->name,tmpContent->value);
-	  else
-	    addToMap(tmpMaps->content,tmpContent->name,tmpContent->value);
+      iotype* tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name,
+					     tmpMaps->content);
+      if(tmpIoType!=NULL){
+	map* tmpContent=tmpIoType->content;
+	map* cval=NULL;
+
+	while(tmpContent!=NULL){
+	  if((cval=getMap(tmpMaps->content,tmpContent->name))==NULL){
+#ifdef DEBUG
+	    fprintf(stderr,"addDefaultValues %s => %s\n",tmpContent->name,tmpContent->value);
+#endif
+	      if(tmpMaps->content==NULL)
+		tmpMaps->content=createMap(tmpContent->name,tmpContent->value);
+	      else
+		addToMap(tmpMaps->content,tmpContent->name,tmpContent->value);
+	  }
+	  tmpContent=tmpContent->next;
 	}
-	tmpContent=tmpContent->next;
       }
     }
Index: /trunk/zoo-kernel/service_internal_java.c
===================================================================
--- /trunk/zoo-kernel/service_internal_java.c	(revision 56)
+++ /trunk/zoo-kernel/service_internal_java.c	(revision 57)
@@ -104,10 +104,15 @@
       fprintf(stderr,"Function successfully loaded\n");
 #endif
+      jclass scHashMapClass,scHashMap_class;
+      jmethodID scHashMap_constructor;
+      scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
+      scHashMap_class = (*env)->NewGlobalRef(env, scHashMapClass);
+      scHashMap_constructor = (*env)->GetMethodID(env, scHashMap_class, "<init>", "()V");
       /**
        * The 3 standard parameter for each services
        */
-      jobject arg1=HashMap_FromMaps(env,m);
-      jobject arg2=HashMap_FromMaps(env,inputs);
-      jobject arg3=HashMap_FromMaps(env,outputs);
+      jobject arg1=HashMap_FromMaps(env,m,scHashMapClass,scHashMap_class,scHashMap_constructor);
+      jobject arg2=HashMap_FromMaps(env,inputs,scHashMapClass,scHashMap_class,scHashMap_constructor);
+      jobject arg3=HashMap_FromMaps(env,outputs,scHashMapClass,scHashMap_class,scHashMap_constructor);
       jint pValue=0;
 
@@ -115,6 +120,7 @@
       if (pValue != NULL){
 	res=pValue;
-	//inputs=mapsFromHashMap(env,arg2);
-	outputs=mapsFromHashMap(env,arg3);
+	m=mapsFromHashMap(env,arg1,scHashMapClass);
+	*main_conf=m;
+	outputs=mapsFromHashMap(env,arg3,scHashMapClass);
 	*real_outputs=outputs;
 
@@ -123,6 +129,4 @@
 	dumpMaps(inputs);
 	dumpMaps(outputs);
-	/*fprintf(stderr,"printProcessResponse(%i,\"%s\",%i,inputs,outputs);",
-	  getpid(),tmp->value,PyInt_AsLong(pValue));*/
 #endif
       }else{	  
@@ -180,11 +184,6 @@
 }
 
-jobject HashMap_FromMaps(JNIEnv *env,maps* t){
-  jclass scHashMapClass,scHashMap_class;
-  jmethodID scHashMap_constructor;
+jobject HashMap_FromMaps(JNIEnv *env,maps* t,jclass scHashMapClass,jclass scHashMap_class,jmethodID scHashMap_constructor){
   jobject scObject,scObject1;
-  scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
-  scHashMap_class = (*env)->NewGlobalRef(env, scHashMapClass);
-  scHashMap_constructor = (*env)->GetMethodID(env, scHashMap_class, "<init>", "()V");   
   if(scHashMap_constructor!=NULL){
     scObject = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
@@ -204,5 +203,5 @@
       (*env)->CallObjectMethod(env,scObject, put_mid, (*env)->NewStringUTF(env,tmp->name), scObject1);
       tmp=tmp->next;
-    } 
+    }
     return scObject;
   }
@@ -211,5 +210,5 @@
 }
 
-maps* mapsFromHashMap(JNIEnv *env,jobject t){
+maps* mapsFromHashMap(JNIEnv *env,jobject t,jclass scHashMapClass){
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap start\n");
@@ -224,10 +223,7 @@
    * }
    */
-  jclass scHashMapClass,scHashMap_class,scSetClass,scIteratorClass,scMapEntryClass,scSet_class,scMapClass;
+  jclass scHashMap_class,scSetClass,scIteratorClass,scMapEntryClass,scSet_class,scMapClass;
   jmethodID entrySet_mid,iterator_mid,hasNext_mid,next_mid,getKey_mid,getValue_mid;
   jobject scObject,scObject1;
-  scHashMapClass=(*env)->GetObjectClass(env,t);
-  //scMapClass=(*env)->FindClass(env, "java/util/HashMap");
-  //scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
   if(scHashMapClass==NULL){
     fprintf(stderr,"Unable to load java.util.HashMap\n");
@@ -276,12 +272,5 @@
   maps* final_res=NULL;
   map* res=NULL;
-#ifdef DEBUG
-  int i=0;
-#endif
   while((*env)->CallBooleanMethod(env,final_iterator,hasNext_mid)){
-#ifdef DEBUG
-    fprintf(stderr,"mapsFromHashMap loop %d\n",i);
-    i++;
-#endif
     jobject tmp=(*env)->CallObjectMethod(env,final_iterator,next_mid);
 
@@ -289,12 +278,6 @@
     jobject set=(*env)->CallObjectMethod(env,imap,entrySet_mid);
     jobject iterator=(*env)->CallObjectMethod(env,set,iterator_mid);
-#ifdef DEBUG
-    int j=0;
-#endif
+
     while((*env)->CallBooleanMethod(env,iterator,hasNext_mid)){
-#ifdef DEBUG
-      fprintf(stderr,"mapsFromHashMap internal loop %d\n",j);
-      j++;
-#endif
       jobject tmp1=(*env)->CallObjectMethod(env,iterator,next_mid);
       jobject jk=(*env)->CallObjectMethod(env,tmp1,getKey_mid);
@@ -310,18 +293,21 @@
 	res=createMap((*env)->GetStringUTFChars(env, jk, NULL),
 		      (*env)->GetStringUTFChars(env, jv, NULL));
-      }else
+      }else{
 	addToMap(res,(*env)->GetStringUTFChars(env, jk, NULL),
 		 (*env)->GetStringUTFChars(env, jv, NULL));
+      }
     }
     jobject jk=(*env)->CallObjectMethod(env,tmp,getKey_mid);
     maps* cmap=(maps*)malloc(sizeof(maps));
     cmap->name=(*env)->GetStringUTFChars(env, jk, NULL);
+#ifdef DEBUG
+    fprintf(stderr," / %s \n",cmap->name);
+#endif
     cmap->content=res;
     cmap->next=NULL;
-    if(final_res==NULL){
+    if(final_res==NULL)
       final_res=dupMaps(&cmap);
-    }else
+    else
       addMapsToMaps(&final_res,cmap);
-    final_res->next=NULL;
     freeMaps(&cmap);
     free(cmap);
Index: /trunk/zoo-kernel/service_internal_java.h
===================================================================
--- /trunk/zoo-kernel/service_internal_java.h	(revision 56)
+++ /trunk/zoo-kernel/service_internal_java.h	(revision 57)
@@ -35,9 +35,9 @@
 extern "C" {
 #endif
-jobject HashMap_FromMaps(JNIEnv*,maps* t);
-
-maps* mapsFromHashMap(JNIEnv*,jobject t);
-
-int zoo_java_support(maps**,map*,service*,maps**,maps**);
+  jobject HashMap_FromMaps(JNIEnv*,maps*,jclass,jclass,jmethodID);
+  
+  maps* mapsFromHashMap(JNIEnv*,jobject,jclass);
+  
+  int zoo_java_support(maps**,map*,service*,maps**,maps**);
 
 #ifdef __cplusplus
Index: /trunk/zoo-kernel/service_internal_python.c
===================================================================
--- /trunk/zoo-kernel/service_internal_python.c	(revision 56)
+++ /trunk/zoo-kernel/service_internal_python.c	(revision 57)
@@ -108,4 +108,5 @@
 	//*real_inputs=mapsFromPyDict(arg2);
 	//createMapsFromPyDict(real_outputs,arg3);
+	*main_conf=mapsFromPyDict(arg1);
 	*real_outputs=mapsFromPyDict(arg3);
 #ifdef DEBUG
Index: /trunk/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-kernel/zoo_service_loader.c	(revision 56)
+++ /trunk/zoo-kernel/zoo_service_loader.c	(revision 57)
@@ -177,5 +177,5 @@
 #endif
 #ifdef DEBUG
-#ifdef WIN32<
+#ifdef WIN32
     DWORD errstr;
     errstr = GetLastError();
@@ -340,4 +340,5 @@
 		*eres=-1;
 	      }
+  *myMap=m;
   *ioutputs=request_output_real_format;
 }
@@ -850,4 +851,7 @@
       free(REQUEST);
       free(SERVICE_URL);
+      InternetCloseHandle(hInternet);
+      freeService(&s1);
+      free(s1);
       return 0;
     }
@@ -1788,5 +1792,6 @@
   freeService(&s1);
   free(s1);
-  freeMaps(&m);
+  //For Python language support only
+  //freeMaps(&m);
   free(m);
   
