Index: trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.c	(revision 620)
+++ trunk/zoo-project/zoo-kernel/service_internal.c	(revision 621)
@@ -1249,4 +1249,6 @@
     if(tmp1!=NULL)
       xmlNewNsProp(nc1,ns,BAD_CAST "processVersion",BAD_CAST tmp1->value);
+    else
+      xmlNewNsProp(nc1,ns,BAD_CAST "processVersion",BAD_CAST "1");
     map* tmp3=getMapFromMaps(m,"lenv","level");
     addPrefix(m,tmp3,serv);
@@ -1301,5 +1303,7 @@
     else{
       if(j>0)
-	xmlNewProp(nc,BAD_CAST tmp4[j],BAD_CAST "false");      
+	xmlNewProp(nc,BAD_CAST tmp4[j],BAD_CAST "true");
+      else
+	xmlNewNsProp(nc,ns,BAD_CAST "processVersion",BAD_CAST "1");
     }
   }
@@ -1452,5 +1456,5 @@
 	datatype=1;
       }
-      
+
       if(strncmp(type,"Input",5)==0){
 
@@ -1521,7 +1525,7 @@
 		const char* bkt;
 		if ( ( bkt = strchr(pToken, '[') ) != NULL || ( bkt = strchr(pToken, ']') ) != NULL ){
-		    strncpy( tmpStr, pToken, bkt - pToken );
-		    tmpStr[bkt - pToken] = '\0';
-		  }
+		  strncpy( tmpStr, pToken, bkt - pToken );
+		  tmpStr[bkt - pToken] = '\0';
+		}
 	      }
 	      xmlAddChild(nc7,xmlNewText(BAD_CAST tmpStr));
@@ -1608,37 +1612,36 @@
 	
       }
-    
       
-    int oI=0;
-    for(oI=0;oI<13;oI++)
-      if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){
+      int oI=0;
+      for(oI=0;oI<13;oI++)
+	if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){
 #ifdef DEBUG
-	printf("DATATYPE DEFAULT ? %s\n",tmp1->name);
-#endif
-	if(strcmp(tmp1->name,"asReference")!=0 &&
-	   strncasecmp(tmp1->name,"DataType",8)!=0 &&
-	   strcasecmp(tmp1->name,"extension")!=0 &&
-	   strcasecmp(tmp1->name,"value")!=0 &&
-	   strcasecmp(tmp1->name,"AllowedValues")!=0 &&
-	   strncasecmp(tmp1->name,"range",5)!=0){
-	  if(datatype!=1){
-	    char *tmp2=zCapitalize1(tmp1->name);
-	    nc9 = xmlNewNode(NULL, BAD_CAST tmp2);
-	    free(tmp2);
-	  }
-	  else{
-	    char *tmp2=zCapitalize(tmp1->name);
-	    nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2);
-	    free(tmp2);
-	  }
-	  xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value));
-	  xmlAddChild(nc5,nc9);
-	  if(strcasecmp(tmp1->name,"uom")==0)
-	    hasUOM1=true;
-	  hasUOM=true;
-	}else 
+	  printf("DATATYPE DEFAULT ? %s\n",tmp1->name);
+#endif
+	  if(strcmp(tmp1->name,"asReference")!=0 &&
+	     strncasecmp(tmp1->name,"DataType",8)!=0 &&
+	     strcasecmp(tmp1->name,"extension")!=0 &&
+	     strcasecmp(tmp1->name,"value")!=0 &&
+	     strcasecmp(tmp1->name,"AllowedValues")!=0 &&
+	     strncasecmp(tmp1->name,"range",5)!=0){
+	    if(datatype!=1){
+	      char *tmp2=zCapitalize1(tmp1->name);
+	      nc9 = xmlNewNode(NULL, BAD_CAST tmp2);
+	      free(tmp2);
+	    }
+	    else{
+	      char *tmp2=zCapitalize(tmp1->name);
+	      nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2);
+	      free(tmp2);
+	    }
+	    xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value));
+	    xmlAddChild(nc5,nc9);
+	    if(strcasecmp(tmp1->name,"uom")==0)
+	      hasUOM1=true;
+	    hasUOM=true;
+	  }else 
 	  
-	  tmp1=tmp1->next;
-      }
+	    tmp1=tmp1->next;
+	}
     
     
@@ -1792,5 +1795,5 @@
     }
     
-    if((tmp1=getMap(_tmp->content,"value"))!=NULL){
+    if(_tmp!=NULL && (tmp1=getMap(_tmp->content,"value"))!=NULL){
       nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue");
       xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value));
@@ -3200,5 +3203,5 @@
 	 * cf. parseBoundingBox
 	 */
-	if(strcasecmp(tmpInputs->format,"BoundingBoxData")==0){
+	if(tmpInputs->format!=NULL && strcasecmp(tmpInputs->format,"BoundingBoxData")==0){
 	  maps* tmpI=getMaps(*out,tmpInputs->name);
 	  if(tmpI!=NULL){
@@ -3518,5 +3521,5 @@
     FILE* fo=fopen(fname,"w+");
     if(fo==NULL){
-#ifdef DEBUG		
+#ifdef DEBUG
       fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno));
 #endif
@@ -3600,5 +3603,4 @@
       }
       for(int i=0;i<atoi(length->value);i++){
-	
 	char* fcontent;
 	char *mimeType=NULL;
@@ -3608,4 +3610,5 @@
 	char vname1[11];
 	char sname[9];
+	char mname[15];
 	char icname[14];
 	char xname[16];
@@ -3620,4 +3623,5 @@
 	  sprintf(vname,"value_%d",i);
 	  sprintf(sname,"size_%d",i);
+	  sprintf(mname,"mimeType_%d",i);
 	  sprintf(icname,"isCached_%d",i);
 	  sprintf(xname,"Reference_%d",i);
@@ -3625,11 +3629,13 @@
 	  sprintf(cname,"cache_file");
 	  sprintf(vname,"value");
+	  sprintf(sname,"size");
+	  sprintf(mname,"mimeType");
 	  sprintf(icname,"isCached");
-	  sprintf(sname,"size");
 	  sprintf(xname,"Reference");
 	}
 
 	map* tmap=getMapFromMaps(*m,"orequests",vname1);
-	if((tmp1=getMap(content->content,xname))!=NULL && strcasecmp(tmap->value,tmp1->value)==0 ){
+	if((tmp1=getMap(content->content,xname))!=NULL /*&& ((tmap!=NULL && strcasecmp(tmap->value,tmp1->value)==0) )*/){
+
 	  if(getMap(content->content,icname)==NULL){
 	    
@@ -3648,5 +3654,5 @@
 	      mimeType=strdup("none");
 	    else
-		  mimeType=strdup(hInternet->ihandle[index].mimeType);	      
+	      mimeType=strdup(hInternet->ihandle[index].mimeType);	      
 	    
 	    map* tmpMap=getMapOrFill(&content->content,vname,"");
@@ -3669,8 +3675,8 @@
 	    }
 	    addToMap(content->content,sname,ltmp1);
+	    addToMap(content->content,mname,mimeType);
 	    addToCache(*m,tmp1->value,fcontent,mimeType,fsize, NULL, 0);
 	    free(fcontent);
 	    free(mimeType);
-	    dumpMaps(content);
 	    index++;
 
@@ -3688,4 +3694,28 @@
   }
   return 0;
+}
+
+/**
+ * Add a request in the download queue
+ *
+ * @param m the maps containing the settings of the main.cfg file
+ * @param url the url to add to the queue
+ */
+void addRequestToQueue(maps** m,HINTERNET* hInternet,const char* url,bool req){
+  hInternet->waitingRequests[hInternet->nb]=strdup(url);
+  if(req)
+    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
+  maps *oreq=getMaps(*m,"orequests");
+  if(oreq==NULL){
+    oreq=(maps*)malloc(MAPS_SIZE);
+    oreq->name=zStrdup("orequests");
+    oreq->content=createMap("value",url);
+    oreq->next=NULL;
+    addMapsToMaps(m,oreq);
+    freeMaps(&oreq);
+    free(oreq);
+  }else{
+    setMapArray(oreq->content,"value",hInternet->nb-1,url);
+  }
 }
 
@@ -3734,19 +3764,6 @@
     }
 
-  }else{
-    hInternet->waitingRequests[hInternet->nb]=strdup(url);
-    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
-    maps *oreq=getMaps(*m,"orequests");
-    if(oreq==NULL){
-      oreq=(maps*)malloc(MAPS_SIZE);
-      oreq->name=zStrdup("orequests");
-      oreq->content=createMap("value",url);
-      oreq->next=NULL;
-      addMapsToMaps(m,oreq);
-      freeMaps(&oreq);
-      free(oreq);
-    }else{
-      setMapArray(oreq->content,"value",hInternet->nb-1,url);
-    }
+  }else{    
+    addRequestToQueue(m,hInternet,url,true);
     return 0;
   }
@@ -3775,5 +3792,4 @@
   else{
     addToMap(*content,"isCached","true");
-
     map* tmp=getMapFromMaps(*m,"main","cacheDir");
     if(tmp!=NULL){
