Index: /trunk/zoo-project/HISTORY.txt
===================================================================
--- /trunk/zoo-project/HISTORY.txt	(revision 575)
+++ /trunk/zoo-project/HISTORY.txt	(revision 576)
@@ -1,3 +1,5 @@
 Version 1.5.0-dev
+  * Add support for multiple Exception nodes
+  * Add a length key when creating MapArray
   * Add Orfeo Toolbox support for applications as a service
   * Add the otb2zcfg utility to produce zcfg for otb applications
Index: /trunk/zoo-project/zoo-kernel/service.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service.h	(revision 575)
+++ /trunk/zoo-project/zoo-kernel/service.h	(revision 576)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2012 GeoLabs SARL
+ * Copyright (c) 2009-2015 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -475,5 +475,5 @@
     tmp->value[size]=0;
     char sin[128];
-    sprintf(sin,"%ld",size);
+    sprintf(sin,"%d",size);
     addToMap(m,"size",sin);
   }
@@ -611,6 +611,4 @@
       if(size!=NULL)
 	loadMapBinary(out,in,-1);
-    char* tmpSized=NULL;
-    
   }
 
@@ -672,8 +670,15 @@
 
 
-  static void setMapArray(map* m,char* key,int index,char* value){
+  static void setMapArray(map* m,const char* key,int index,const char* value){
     char tmp[1024];
-    if(index>0)
+    if(index>0){
       sprintf(tmp,"%s_%d",key,index);
+      map* len=getMap(m,"length");
+      if((len!=NULL && atoi(len->value)<index+1) || len==NULL){
+	char tmp0[5];
+	sprintf(tmp0,"%d",index+1);
+	addToMap(m,"length",tmp0);
+      }
+    }
     else
       sprintf(tmp,"%s",key);
Index: /trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 575)
+++ /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 576)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2013 GeoLabs SARL
+ * Copyright (c) 2009-2015 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -399,5 +399,5 @@
             }
         }
-	errno = NULL;
+	errno = ZOO_LOCK_ACQUIRE_FAILED;
         if (!ready) {
 #ifdef DEBUG
@@ -428,5 +428,4 @@
 int lockShm(int id){
   struct sembuf sb;
-  int i;
   sb.sem_num = 0;
   sb.sem_op = -1;  /* set to allocate resource */
@@ -629,13 +628,13 @@
 
 char *zCapitalize1(char *tmp){
-        char *res=strdup(tmp);
-        if(res[0]>=97 && res[0]<=122)
-                res[0]-=32;
-        return res;
+  char *res=zStrdup(tmp);
+  if(res[0]>=97 && res[0]<=122)
+    res[0]-=32;
+  return res;
 }
 
 char *zCapitalize(char *tmp){
   int i=0;
-  char *res=strdup(tmp);
+  char *res=zStrdup(tmp);
   for(i=0;i<strlen(res);i++)
     if(res[i]>=97 && res[i]<=122)
@@ -713,4 +712,17 @@
 
 
+/************************************************************************/
+/*                             soapEnvelope()                           */
+/************************************************************************/
+
+/**
+ * Generate a SOAP Envelope node when required (if the isSoap key of the [main]
+ * section is set to true).
+ * 
+ * @param conf the conf maps containing the main.cfg settings
+ * @param n the node used as children of the generated soap:Envelope
+ * @return the generated soap:Envelope (if isSoap=true) or the input node n 
+ *  (when isSoap=false)
+ */
 xmlNodePtr soapEnvelope(maps* conf,xmlNodePtr n){
   map* soap=getMapFromMaps(conf,"main","isSoap");
@@ -737,40 +749,70 @@
 }
 
-xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr doc,const char* service,maps* m){
-
-  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
+/************************************************************************/
+/*                            printWPSHeader()                          */
+/************************************************************************/
+
+/**
+ * Generate a WPS header.
+ * 
+ * @param doc the document to add the header
+ * @param m the conf maps containing the main.cfg settings
+ * @param req the request type (GetCapabilities,DescribeProcess,Execute)
+ * @param rname the root node name
+ * @return the generated wps:rname xmlNodePtr (can be wps: Capabilities, 
+ *  wps:ProcessDescriptions,wps:ExecuteResponse)
+ */
+xmlNodePtr printWPSHeader(xmlDocPtr doc,maps* m,const char* req,const char* rname){
+
+  xmlNsPtr ns,ns_xsi;
+  xmlNodePtr n;
+
+  int wpsId=zooXmlAddNs(NULL,"http://schemas.opengis.net/wps/1.0.0","wps");
+  ns=usedNs[wpsId];
+  n = xmlNewNode(ns, BAD_CAST rname);
+  zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
+  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
+  zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
+  int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
+  ns_xsi=usedNs[xsiId];
+  
+  char *tmp=(char*) malloc((86+strlen(req)+1)*sizeof(char));
+  sprintf(tmp,"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wps%s_response.xsd",req);
+  xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST tmp);
+  free(tmp);
+  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
+  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
+  addLangAttr(n,m);
+  xmlNodePtr fn=soapEnvelope(m,n);
+  xmlDocSetRootElement(doc, fn);
+  return n;
+}
+
+/************************************************************************/
+/*                     printGetCapabilitiesHeader()                     */
+/************************************************************************/
+
+/**
+ * Generate a Capabilities header.
+ * 
+ * @param doc the document to add the header
+ * @param m the conf maps containing the main.cfg settings
+ * @return the generated wps:ProcessOfferings xmlNodePtr 
+ */
+xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr doc,maps* m){
+
+  xmlNsPtr ns,ns_ows,ns_xlink;
   xmlNodePtr n,nc,nc1,nc2,nc3,nc4,nc5,nc6;
-  /**
-   * Create the document and its temporary root.
-   */
+  n = printWPSHeader(doc,m,"GetCapabilities","Capabilities");
+  maps* toto1=getMaps(m,"main");
+  char tmp[256];
+
   int wpsId=zooXmlAddNs(NULL,"http://www.opengis.net/wps/1.0.0","wps");
   ns=usedNs[wpsId];
-  maps* toto1=getMaps(m,"main");
-
-  n = xmlNewNode(ns, BAD_CAST "Capabilities");
-  int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
+  int xlinkId=zooXmlAddNs(NULL,"http://www.w3.org/1999/xlink","xlink");
+  ns_xlink=usedNs[xlinkId];
+  int owsId=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows");
   ns_ows=usedNs[owsId];
-  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
-  int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
-  ns_xsi=usedNs[xsiId];
-  int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
-  ns_xlink=usedNs[xlinkId];
-  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/wpsGetCapabilities_response.xsd"); 
-  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
-  addLangAttr(n,m);
-  
-  if(toto1!=NULL){
-    map* tmp=getMap(toto1->content,"version");
-    if(tmp!=NULL){
-      xmlNewProp(n,BAD_CAST "version",BAD_CAST tmp->value);
-    }
-    else
-      xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
-  }
-  else
-    xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
-
-  char tmp[256];
-  
+
   nc = xmlNewNode(ns_ows, BAD_CAST "ServiceIdentification");
   maps* tmp4=getMaps(m,"identification");
@@ -827,5 +869,5 @@
 	    nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceTypeVersion");
 	    xmlAddChild(nc2,xmlNewText(BAD_CAST "1.0.0"));
-	    xmlAddChild(nc,nc2);	  
+	    xmlAddChild(nc,nc2);
 	  }
 	tmp2=tmp2->next;
@@ -972,8 +1014,8 @@
     }
     else
-      SERVICE_URL = strdup("not_found");
+      SERVICE_URL = strdup("not_defined");
   }
   else
-    SERVICE_URL = strdup("not_found");
+    SERVICE_URL = strdup("not_defined");
 
   for(j=0;j<3;j++){
@@ -983,12 +1025,10 @@
     nc3 = xmlNewNode(ns_ows, BAD_CAST "HTTP");
     nc4 = xmlNewNode(ns_ows, BAD_CAST "Get");
-    sprintf(tmp,"%s/%s",SERVICE_URL,service);
+    sprintf(tmp,"%s",SERVICE_URL);
     xmlNewNsProp(nc4,ns_xlink,BAD_CAST "href",BAD_CAST tmp);
     xmlAddChild(nc3,nc4);
-    if(j>0){
-      nc4 = xmlNewNode(ns_ows, BAD_CAST "Post");
-      xmlNewNsProp(nc4,ns_xlink,BAD_CAST "href",BAD_CAST tmp);
-      xmlAddChild(nc3,nc4);
-    }
+    nc4 = xmlNewNode(ns_ows, BAD_CAST "Post");
+    xmlNewNsProp(nc4,ns_xlink,BAD_CAST "href",BAD_CAST tmp);
+    xmlAddChild(nc3,nc4);
     xmlAddChild(nc2,nc3);
     xmlAddChild(nc1,nc2);    
@@ -1045,10 +1085,8 @@
   xmlAddChild(n,nc1);
   
-  xmlNodePtr fn=soapEnvelope(m,n);
-  xmlDocSetRootElement(doc, fn);
-  //xmlFreeNs(ns);
   free(SERVICE_URL);
   return nc;
 }
+
 
 void addPrefix(maps* conf,map* level,service* serv){
@@ -1115,29 +1153,4 @@
     xmlAddChild(nc,nc1);
   }
-}
-
-xmlNodePtr printDescribeProcessHeader(xmlDocPtr doc,const char* service,maps* m){
-
-  xmlNsPtr ns,ns_xsi;
-  xmlNodePtr n;
-
-  int wpsId=zooXmlAddNs(NULL,"http://schemas.opengis.net/wps/1.0.0","wps");
-  ns=usedNs[wpsId];
-  n = xmlNewNode(ns, BAD_CAST "ProcessDescriptions");
-  zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
-  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
-  zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
-  int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
-  ns_xsi=usedNs[xsiId];
-  
-  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/wpsDescribeProcess_response.xsd");
-  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
-  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
-  addLangAttr(n,m);
-
-  xmlNodePtr fn=soapEnvelope(m,n);
-  xmlDocSetRootElement(doc, fn);
-
-  return n;
 }
 
@@ -1668,5 +1681,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,ns_ows,ns_xlink;
   xmlNodePtr nr,n,nc,nc1=NULL,nc3;
   xmlDocPtr doc;
@@ -1674,25 +1687,12 @@
   time(&time1);
   nr=NULL;
-  /**
-   * Create the document and its temporary root.
-   */
   doc = xmlNewDoc(BAD_CAST "1.0");
+  n = printWPSHeader(doc,m,"Execute","ExecuteResponse");
   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");
+  int owsId=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows");
   ns_ows=usedNs[owsId];
-  int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
+  int xlinkId=zooXmlAddNs(NULL,"http://www.w3.org/1999/xlink","xlink");
   ns_xlink=usedNs[xlinkId];
-  int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
-  ns_xsi=usedNs[xsiId];
-  
-  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");
-  
-  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
-  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
-  addLangAttr(n,m);
 
   char tmp[256];
@@ -1876,5 +1876,5 @@
     while(mcursor!=NULL){
       scursor=getElements(serv->outputs,mcursor->name);
-      printOutputDefinitions1(doc,nc,ns,ns_ows,scursor,mcursor,"Output");
+      printOutputDefinitions(doc,nc,ns,ns_ows,scursor,mcursor,"Output");
       mcursor=mcursor->next;
     }
@@ -1915,10 +1915,4 @@
   }
 
-#ifdef DEBUG
-  fprintf(stderr,"printProcessResponse 1 202\n");
-#endif
-  nr=soapEnvelope(m,n);
-  xmlDocSetRootElement(doc, nr);
-
   if(hasStoredExecuteResponse==true && status!=SERVICE_STARTED){
     semid lid=getShmLockId(m,1);
@@ -1936,9 +1930,6 @@
 	char tmpMsg[1024];
 	sprintf(tmpMsg,_("Unable to create the file : \"%s\" for storing the ExecuteResponse."),stored_path);
-	map * errormap = createMap("text",tmpMsg);
-	addToMap(errormap,"code", "InternalError");
-	printExceptionReportResponse(m,errormap);
-	freeMap(&errormap);
-	free(errormap);
+
+	errorException(m,tmpMsg,"InternalError",NULL);
 	xmlFreeDoc(doc);
 	xmlCleanupParser();
@@ -1995,5 +1986,5 @@
 }
 
-void printOutputDefinitions1(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,maps* m,const char* type){
+void printOutputDefinitions(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,maps* m,const char* type){
   xmlNodePtr nc1;
   nc1=xmlNewNode(ns_wps, BAD_CAST type);
@@ -2012,32 +2003,4 @@
        || strncasecmp(tmp->name,"SCHEMA",strlen(tmp->name))==0
        || strncasecmp(tmp->name,"UOM",strlen(tmp->name))==0)
-    xmlNewProp(nc1,BAD_CAST tmp->name,BAD_CAST tmp->value);
-    tmp=tmp->next;
-  }
-  tmp=getMap(e->defaults->content,"asReference");
-  if(tmp==NULL)
-    xmlNewProp(nc1,BAD_CAST "asReference",BAD_CAST "false");
-
-  tmp=e->content;
-
-  printDescription(nc1,ns_ows,m->name,e->content);
-
-  xmlAddChild(nc,nc1);
-
-}
-
-void printOutputDefinitions(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,map* m,const char* type){
-  xmlNodePtr nc1;
-  nc1=xmlNewNode(ns_wps, BAD_CAST type);
-  map *tmp=NULL;  
-  if(e!=NULL && e->defaults!=NULL)
-    tmp=e->defaults->content;
-  else{
-    /*
-    dumpElements(e);
-    */
-    return;
-  }
-  while(tmp!=NULL){
     xmlNewProp(nc1,BAD_CAST tmp->name,BAD_CAST tmp->value);
     tmp=tmp->next;
@@ -2212,5 +2175,5 @@
 	if(rs==NULL){
 	  char tmp1[1024];
-	  sprintf(tmp1,"%u",strlen(tmp3->value));
+	  sprintf(tmp1,"%ld",strlen(tmp3->value));
 	  rs=createMap("size",tmp1);
 	  isSized=false;
@@ -2335,4 +2298,16 @@
 }
 
+/************************************************************************/
+/*                    printExceptionReportResponse()                    */
+/************************************************************************/
+
+/**
+ * Print an OWS ExceptionReport Document and HTTP headers (when required) 
+ * depending on the code.
+ * Set hasPrinted value to true in the [lenv] section.
+ * 
+ * @param m the conf maps
+ * @param s the map containing the text,code,locator keys
+ */
 void printExceptionReportResponse(maps* m,map* s){
   if(getMapFromMaps(m,"lenv","hasPrinted")!=NULL)
@@ -2351,5 +2326,6 @@
   map* tmp=getMap(s,"code");
   if(tmp!=NULL){
-    if(strcmp(tmp->value,"OperationNotSupported")==0)
+    if(strcmp(tmp->value,"OperationNotSupported")==0 ||
+       strcmp(tmp->value,"NoApplicableCode")==0)
       exceptionCode="501 Not Implemented";
     else
@@ -2361,8 +2337,5 @@
 	exceptionCode="400 Bad request";
       else
-	if(strcmp(tmp->value,"NoApplicableCode")==0)
-	  exceptionCode="501 Internal Server Error";
-	else
-	  exceptionCode="501 Internal Server Error";
+	exceptionCode="501 Internal Server Error";
   }
   else
@@ -2397,4 +2370,17 @@
 }
 
+/************************************************************************/
+/*                      createExceptionReportNode()                     */
+/************************************************************************/
+
+/**
+ * Create an OWS ExceptionReport Node.
+ * 
+ * @param m the conf maps
+ * @param s the map containing the text,code,locator keys
+ * @param use_ns (0/1) choose if you want to generate an ExceptionReport or 
+ *  ows:ExceptionReport node respectively
+ * @return the ExceptionReport/ows:ExceptionReport node
+ */
 xmlNodePtr createExceptionReportNode(maps* m,map* s,int use_ns){
   
@@ -2404,10 +2390,10 @@
   int nsid=zooXmlAddNs(NULL,"http://www.opengis.net/ows","ows");
   ns=usedNs[nsid];
-  if(use_ns==1){
+  if(use_ns==0){
     ns=NULL;
   }
   n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
   if(use_ns==1){
-    xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",NULL);
+    xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST"ows");
     int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
     ns_xsi=usedNs[xsiId];
@@ -2419,29 +2405,66 @@
   xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
   
-  nc = xmlNewNode(ns, BAD_CAST "Exception");
-
-  map* tmp=getMap(s,"code");
-  if(tmp!=NULL)
-    xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST tmp->value);
+  int length=1;
+  int cnt=0;
+  map* len=getMap(s,"length");
+  if(len!=NULL)
+    length=atoi(len->value);
+  fprintf(stderr,"LEN %d %s %d \n",length,__FILE__,__LINE__);
+  for(cnt=0;cnt<length;cnt++){
+    nc = xmlNewNode(ns, BAD_CAST "Exception");
+    
+    map* tmp=getMapArray(s,"code",cnt);
+    if(tmp==NULL)
+      tmp=getMap(s,"code");
+    if(tmp!=NULL)
+      xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST tmp->value);
+    else
+      xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode");
+    
+    tmp=getMapArray(s,"locator",cnt);
+    if(tmp==NULL)
+      tmp=getMap(s,"locator");
+    if(tmp!=NULL && strcasecmp(tmp->value,"NULL")!=0)
+      xmlNewProp(nc,BAD_CAST "locator",BAD_CAST tmp->value);
+
+    tmp=getMapArray(s,"text",cnt);
+    nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
+    if(tmp!=NULL){
+      xmlNodePtr txt=xmlNewText(BAD_CAST tmp->value);
+      xmlAddChild(nc1,txt);
+    }
+    else{
+      xmlNodeSetContent(nc1, BAD_CAST _("No debug message available"));
+    }
+    xmlAddChild(nc,nc1);
+    xmlAddChild(n,nc);
+  }
+  return n;
+}
+
+/************************************************************************/
+/*                           errorException()                           */
+/************************************************************************/
+
+/**
+ * Print an OWS ExceptionReport.
+ * 
+ * @param m the conf maps
+ * @param message the error message 
+ * @param errorcode the error code
+ * @param locator the potential locator
+ */
+int errorException(maps *m, const char *message, const char *errorcode, const char *locator) 
+{
+  map* errormap = createMap("text", message);
+  addToMap(errormap,"code", errorcode);
+  if(locator!=NULL)
+    addToMap(errormap,"locator", locator);
   else
-    xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode");
-
-  tmp=getMap(s,"locator");
-  if(tmp!=NULL && strcasecmp(tmp->value,"NULL")!=0)
-    xmlNewProp(nc,BAD_CAST "locator",BAD_CAST tmp->value);
-
-
-  tmp=getMap(s,"text");
-  nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
-  if(tmp!=NULL){
-    xmlNodePtr txt=xmlNewText(BAD_CAST tmp->value);
-    xmlAddChild(nc1,txt);
-  }
-  else{
-    xmlNodeSetContent(nc1, BAD_CAST _("No debug message available"));
-  }
-  xmlAddChild(nc,nc1);
-  xmlAddChild(n,nc);
-  return n;
+    addToMap(errormap,"locator", "NULL");
+  printExceptionReportResponse(m,errormap);
+  freeMap(&errormap);
+  free(errormap);
+  return -1;
 }
 
@@ -2479,5 +2502,5 @@
   fclose(file);
   char rsize[100];
-  sprintf(rsize,"%d",count*sizeof(char));
+  sprintf(rsize,"%ld",count*sizeof(char));
   addToMap(tmpMap1,"size",rsize);
 }
@@ -2529,10 +2552,6 @@
       char tmpMsg[1024];
       sprintf(tmpMsg,_("Unable to create the file : \"%s\" for storing the session maps."),session_file_path);
-      map * errormap = createMap("text",tmpMsg);
-      addToMap(errormap,"code", "InternalError");
-      
-      printExceptionReportResponse(m,errormap);
-      freeMap(&errormap);
-      free(errormap);
+      errorException(m,tmpMsg,"InternalError",NULL);
+
       return;
     }
@@ -2543,28 +2562,23 @@
   }
   
-    if(res==SERVICE_FAILED){
-      map * errormap;
-      map *lenv;
-      lenv=getMapFromMaps(m,"lenv","message");
-      char *tmp0;
-      if(lenv!=NULL){
-	tmp0=(char*)malloc((strlen(lenv->value)+strlen(_("Unable to run the Service. The message returned back by the Service was the following: "))+1)*sizeof(char));
-	sprintf(tmp0,_("Unable to run the Service. The message returned back by the Service was the following: %s"),lenv->value);
-      }
-      else{
-	tmp0=(char*)malloc((strlen(_("Unable to run the Service. No more information was returned back by the Service."))+1)*sizeof(char));
-	sprintf(tmp0,_("Unable to run the Service. No more information was returned back by the Service."));
-      }
-      errormap = createMap("text",tmp0);
-      free(tmp0);
-      addToMap(errormap,"code", "InternalError");
-      dumpMap(errormap);
-      printExceptionReportResponse(m,errormap);
-      freeMap(&errormap);
-      free(errormap);
-      return;
-    }
-
-
+  if(res==SERVICE_FAILED){
+    map *lenv;
+    lenv=getMapFromMaps(m,"lenv","message");
+    char *tmp0;
+    if(lenv!=NULL){
+      tmp0=(char*)malloc((strlen(lenv->value)+strlen(_("Unable to run the Service. The message returned back by the Service was the following: "))+1)*sizeof(char));
+      sprintf(tmp0,_("Unable to run the Service. The message returned back by the Service was the following: %s"),lenv->value);
+    }
+    else{
+      tmp0=(char*)malloc((strlen(_("Unable to run the Service. No more information was returned back by the Service."))+1)*sizeof(char));
+      sprintf(tmp0,"%s",_("Unable to run the Service. No more information was returned back by the Service."));
+    }
+    errorException(m,tmp0,"InternalError",NULL);
+    free(tmp0);
+    return;
+  }
+
+
+  map *tmp1=getMapFromMaps(m,"main","tmpPath");
   if(asRaw==0){
 #ifdef DEBUG
@@ -2573,4 +2587,5 @@
 #endif
     maps* tmpI=request_outputs;
+
     while(tmpI!=NULL){
 #ifdef USE_MS
@@ -2596,6 +2611,4 @@
 	    addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd");
 	  }
-
-	  map *tmp1=getMapFromMaps(m,"main","tmpPath");
 
 	  map *gfile=getMap(tmpI->content,"generated_file");
@@ -2648,9 +2661,5 @@
 	      char tmpMsg[1024];
 	      sprintf(tmpMsg,_("Unable to create the file : \"%s\" for storing the %s final result."),file_name,tmpI->name);
-	      map * errormap = createMap("text",tmpMsg);
-	      addToMap(errormap,"code", "InternalError");
-	      printExceptionReportResponse(m,errormap);
-	      freeMap(&errormap);
-	      free(errormap);
+	      errorException(m,tmpMsg,"InternalError",NULL);
 	      free(file_name);
 	      free(file_path);
@@ -2730,4 +2739,8 @@
       map *gfile=getMap(tmpI->content,"generated_file");
       if(gfile!=NULL){
+	gfile=getMap(tmpI->content,"expected_generated_file");
+	if(gfile==NULL){
+	  gfile=getMap(tmpI->content,"generated_file");
+	}
 	readGeneratedFile(m,tmpI->content,gfile->value);
       }
@@ -2736,9 +2749,5 @@
 	char tmpMsg[1024];
 	sprintf(tmpMsg,_("Wrong RawDataOutput parameter, unable to fetch any result for the name your provided : \"%s\"."),tmpI->name);
-	map * errormap = createMap("text",tmpMsg);
-	addToMap(errormap,"code", "InvalidParameterValue");
-	printExceptionReportResponse(m,errormap);
-	freeMap(&errormap);
-	free(errormap);
+	errorException(m,tmpMsg,"InvalidParameterValue","RawDataOutput");
 	return;
       }
@@ -2842,12 +2851,26 @@
 }
 
-char* addDefaultValues(maps** out,elements* in,maps* m,int type){
+char* addDefaultValues(maps** out,elements* in,maps* m,int type,map** err){
+  map *res=*err;
   elements* tmpInputs=in;
   maps* out1=*out;
+  char *result=NULL;
+  int nb=0;
   if(type==1){
     while(out1!=NULL){
-      if(getElements(in,out1->name)==NULL)
-	return out1->name;
+      if(getElements(in,out1->name)==NULL){
+	if(res==NULL){
+	  res=createMap("value",out1->name);
+	}else{
+	  setMapArray(res,"value",nb,out1->name);
+	}
+	nb++;
+	result=out1->name;
+      }
       out1=out1->next;
+    }
+    if(res!=NULL){
+      *err=res;
+      return result;
     }
     out1=*out;
@@ -2867,5 +2890,11 @@
 	    freeMaps(&tmpMaps2);
 	    free(tmpMaps2);
-	    return tmpInputs->name;
+	    if(res==NULL){
+	      res=createMap("value",tmpInputs->name);
+	    }else{
+	      setMapArray(res,"value",nb,tmpInputs->name);
+	    }
+	    nb++;
+	    result=tmpInputs->name;
 	  }
 	  else{
@@ -2876,49 +2905,53 @@
 	  }
 	}
-	map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs");
-	if(tmpMaxO!=NULL){
-	  if(tmpMaps2->content==NULL)
-	    tmpMaps2->content=createMap("maxOccurs",tmpMaxO->value);
-	  else
-	    addToMap(tmpMaps2->content,"maxOccurs",tmpMaxO->value);
-	}
-	map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes");
-	if(tmpMaxMB!=NULL){
-	  if(tmpMaps2->content==NULL)
-	    tmpMaps2->content=createMap("maximumMegabytes",tmpMaxMB->value);
-	  else
-	    addToMap(tmpMaps2->content,"maximumMegabytes",tmpMaxMB->value);
-	}
-      }
-
-      iotype* tmpIoType=tmpInputs->defaults;
-      if(tmpIoType!=NULL){
-	map* tmpm=tmpIoType->content;
-	while(tmpm!=NULL){
-	  if(tmpMaps2->content==NULL)
-	    tmpMaps2->content=createMap(tmpm->name,tmpm->value);
-	  else
-	    addToMap(tmpMaps2->content,tmpm->name,tmpm->value);
-	  tmpm=tmpm->next;
-	}
-      }
-      addToMap(tmpMaps2->content,"inRequest","false");
-      if(type==0){
-	map *tmpMap=getMap(tmpMaps2->content,"value");
-	if(tmpMap==NULL)
-	  addToMap(tmpMaps2->content,"value","NULL");
-      }
-      if(out1==NULL){
-	*out=dupMaps(&tmpMaps2);
-	out1=*out;
-      }
-      else
-	addMapsToMaps(&out1,tmpMaps2);
-      freeMap(&tmpMaps2->content);
-      free(tmpMaps2->content);
-      tmpMaps2->content=NULL;
-      freeMaps(&tmpMaps2);
-      free(tmpMaps2);
-      tmpMaps2=NULL;
+	if(res==NULL){
+	  map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs");
+	  if(tmpMaxO!=NULL){
+	    if(tmpMaps2->content==NULL)
+	      tmpMaps2->content=createMap("maxOccurs",tmpMaxO->value);
+	    else
+	      addToMap(tmpMaps2->content,"maxOccurs",tmpMaxO->value);
+	  }
+	  map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes");
+	  if(tmpMaxMB!=NULL){
+	    if(tmpMaps2->content==NULL)
+	      tmpMaps2->content=createMap("maximumMegabytes",tmpMaxMB->value);
+	    else
+	      addToMap(tmpMaps2->content,"maximumMegabytes",tmpMaxMB->value);
+	  }
+	}
+      }
+
+      if(res==NULL){
+	iotype* tmpIoType=tmpInputs->defaults;
+	if(tmpIoType!=NULL){
+	  map* tmpm=tmpIoType->content;
+	  while(tmpm!=NULL){
+	    if(tmpMaps2->content==NULL)
+	      tmpMaps2->content=createMap(tmpm->name,tmpm->value);
+	    else
+	      addToMap(tmpMaps2->content,tmpm->name,tmpm->value);
+	    tmpm=tmpm->next;
+	  }
+	}
+	addToMap(tmpMaps2->content,"inRequest","false");
+	if(type==0){
+	  map *tmpMap=getMap(tmpMaps2->content,"value");
+	  if(tmpMap==NULL)
+	    addToMap(tmpMaps2->content,"value","NULL");
+	}
+	if(out1==NULL){
+	  *out=dupMaps(&tmpMaps2);
+	  out1=*out;
+	}
+	else
+	  addMapsToMaps(&out1,tmpMaps2);
+	freeMap(&tmpMaps2->content);
+	free(tmpMaps2->content);
+	tmpMaps2->content=NULL;
+	freeMaps(&tmpMaps2);
+	free(tmpMaps2);
+	tmpMaps2=NULL;
+      }
     }
     else{
@@ -3048,4 +3081,8 @@
     }
     tmpInputs=tmpInputs->next;
+  }
+  if(res!=NULL){
+    *err=res;
+    return result;
   }
   return "";
@@ -3381,4 +3418,5 @@
     
   }
+  return 0;
 }
 
@@ -3480,19 +3518,4 @@
 }
 
-int errorException(maps *m, const char *message, const char *errorcode, const char *locator) 
-{
-  map* errormap = createMap("text", message);
-  addToMap(errormap,"code", errorcode);
-  if(locator!=NULL)
-    addToMap(errormap,"locator", locator);
-  else
-    addToMap(errormap,"locator", "NULL");
-  printExceptionReportResponse(m,errormap);
-  freeMap(&errormap);
-  free(errormap);
-  return -1;
-}
-
-
 char *readVSIFile(maps* conf,const char* dataSource){
     VSILFILE * fichier=VSIFOpenL(dataSource,"rb");
@@ -3501,5 +3524,5 @@
     if(fichier==NULL){
       char tmp[1024];
-      sprintf(tmp,"Failed to open file %s for reading purpose. File seems empty %d.",
+      sprintf(tmp,"Failed to open file %s for reading purpose. File seems empty %lld.",
 	      dataSource,file_status.st_size);
       setMapInMaps(conf,"lenv","message",tmp);
@@ -3620,2 +3643,93 @@
   return 0;
 }
+
+/************************************************************************/
+/*                           checkValidValue()                          */
+/************************************************************************/
+
+/**
+ * Verify if a parameter value is valid.
+ * 
+ * @param request the request map
+ * @param res the error map potentially generated
+ * @param avalues the acceptable values (or null if testing only for presence)
+ * @param mandatory verify the presence of the parameter if mandatory > 0 
+ */
+void checkValidValue(map* request,map** res,const char* toCheck,const char** avalues,int mandatory){
+  map* lres=*res;
+  map* r_inputs = getMap (request,toCheck);
+  if (r_inputs == NULL){
+    if(mandatory>0){
+      char *replace=_("Mandatory parameter <%s> was not specified");
+      char *message=(char*)malloc((strlen(replace)+strlen(toCheck)+1)*sizeof(char));
+      sprintf(message,replace,toCheck);
+      if(lres==NULL){
+	lres=createMap("code","MissingParameterValue");
+	addToMap(lres,"text",message);
+	addToMap(lres,"locator",toCheck);       
+      }else{
+	int length=1;
+	map* len=getMap(lres,"length");
+	if(len!=NULL){
+	  length=atoi(len->value);
+	}
+	setMapArray(lres,"text",length,message);
+	setMapArray(lres,"locator",length,toCheck);
+	setMapArray(lres,"code",length,"MissingParameter");
+      }
+      free(message);
+    }
+  }else{
+    if(avalues==NULL)
+      return;
+    int nb=0;
+    int hasValidValue=-1;
+    while(avalues[nb]!=NULL){
+      if(strcasecmp(avalues[nb],r_inputs->value)==0){
+	hasValidValue=1;
+	break;
+      }
+      nb++;
+    }
+    if(hasValidValue<0){
+      char *replace=_("Ununderstood <%s> value, %s %s the only acceptable value.");
+      nb=0;
+      char *vvalues=NULL;
+      char* num=_("is");
+      while(avalues[nb]!=NULL){
+	char *tvalues;
+	if(vvalues==NULL){
+	  vvalues=(char*)malloc((strlen(avalues[nb])+3)*sizeof(char));
+	  sprintf(vvalues,"%s",avalues[nb]);
+	}
+	else{
+	  tvalues=zStrdup(vvalues);
+	  vvalues=(char*)realloc(vvalues,(strlen(tvalues)+strlen(avalues[nb])+3)*sizeof(char));
+	  sprintf(vvalues,"%s, %s",tvalues,avalues[nb]);
+	  free(tvalues);
+	  num=_("are");
+	}
+	nb++;
+      }
+      char *message=(char*)malloc((strlen(replace)+strlen(num)+strlen(vvalues)+strlen(toCheck)+1)*sizeof(char));
+      sprintf(message,replace,toCheck,vvalues,num);
+      if(lres==NULL){
+	lres=createMap("code","InvalidParameterValue");
+	addToMap(lres,"text",message);
+	addToMap(lres,"locator",toCheck);       
+      }else{
+	int length=1;
+	map* len=getMap(lres,"length");
+	if(len!=NULL){
+	  length=atoi(len->value);
+	}
+	setMapArray(lres,"text",length,message);
+	setMapArray(lres,"locator",length,toCheck);
+	setMapArray(lres,"code",length,"InvalidParameterValue");
+      }
+    }
+  }
+  if(lres!=NULL){
+    *res=lres;
+  }
+}
Index: /trunk/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.h	(revision 575)
+++ /trunk/zoo-project/zoo-kernel/service_internal.h	(revision 576)
@@ -99,4 +99,5 @@
   int readServiceFile(maps*, char*,service**,char *);
   int isValidLang(maps*,const char*);
+  void addLangAttr(xmlNodePtr,maps*);
 
   void printHeaders(maps*);
@@ -137,7 +138,7 @@
   xmlNodePtr createExceptionReportNode(maps*,map*,int);
   void printProcessResponse(maps*,map*,int,service*,const char*,int,maps*,maps*);
-  xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,const char*,maps*);
+  xmlNodePtr printWPSHeader(xmlDocPtr,maps*,const char*,const char*);
+  xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,maps*);
   void printGetCapabilitiesForProcess(maps*,xmlNodePtr,service*);
-  xmlNodePtr printDescribeProcessHeader(xmlDocPtr,const char*,maps*);
   void printDescribeProcessForProcess(maps*,xmlNodePtr,service*);
   void printFullDescription(int,elements*,const char*,xmlNsPtr,xmlNodePtr);
@@ -148,6 +149,6 @@
   void printBoundingBox(xmlNsPtr,xmlNodePtr,map*);
   void printBoundingBoxDocument(maps*,maps*,FILE*);
-  void printOutputDefinitions1(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*);
-  
+  void printOutputDefinitions(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*);
+
   void outputResponse(service*,maps*,maps*,map*,int,maps*,int);
 
@@ -155,9 +156,10 @@
   char *base64d(const char*,int,int*);
   void ensureDecodedBase64(maps**);
-
-  char* addDefaultValues(maps**,elements*,maps*,int);
+  void checkValidValue(map*,map**,const char*,const char**,int);
+  char* addDefaultValues(maps**,elements*,maps*,int,map**);
 
   int errorException(maps *, const char *, const char *, const char*);
 
+  xmlNodePtr soapEnvelope(maps*,xmlNodePtr);
   int checkForSoapEnvelope(xmlDocPtr);
 
Index: /trunk/zoo-project/zoo-kernel/service_internal_js.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 575)
+++ /trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 576)
@@ -200,9 +200,5 @@
     sprintf(tmp1,"Unable to load JavaScript file %s",filename);
     free(filename);
-    map* err=createMap("text",tmp1);
-    addToMap(err,"code","NoApplicableCode");
-    printExceptionReportResponse(mc,err);
-    freeMap(&err);
-    free(err);
+    errorException(*main_conf,tmp1,"NoApplicableCode",NULL);
     JS_MaybeGC(cx);
     JS_DestroyContext(cx);
@@ -248,9 +244,5 @@
     fprintf(stderr,"%s",tmp1);
 #endif
-    map* err=createMap("text",tmp1);
-    addToMap(err,"code","NoApplicableCode");
-    printExceptionReportResponse(*main_conf,err);
-    freeMap(&err);
-    free(err);
+    errorException(*main_conf,tmp1,"NoApplicableCode",NULL);
     free(filename);
     JS_MaybeGC(cx);
Index: /trunk/zoo-project/zoo-kernel/service_internal_otb.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_otb.c	(revision 575)
+++ /trunk/zoo-project/zoo-kernel/service_internal_otb.c	(revision 576)
@@ -137,5 +137,5 @@
 		    else if (strncasecmp(test->value,"double",6)==0)
 		      outPixType = ImagePixelType_double;
-		    char* ext="tiff";
+		    const char* ext="tiff";
 		    if(tmpVal!=NULL){
 		      if(strncasecmp(tmpVal->value,"image/jp2",9)==0)
Index: /trunk/zoo-project/zoo-kernel/service_internal_python.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 575)
+++ /trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 576)
@@ -215,7 +215,5 @@
   }
   else{
-    map* err=createMap("text","Unable to parse serviceProvider please check your zcfg file.");
-    addToMap(err,"code","NoApplicableCode");
-    printExceptionReportResponse(m,err);
+    errorException (m, "Unable to parse serviceProvider please check your zcfg file.", "NoApplicableCode", NULL);
     exit(-1);
   }
@@ -250,39 +248,5 @@
 #endif
       }else{	  
-	PyObject *ptype,*pvalue, *ptraceback;
-	PyErr_Fetch(&ptype, &pvalue, &ptraceback);
-	PyObject *trace=PyObject_Str(pvalue);
-	char pbt[10240];
-	if(PyString_Check(trace))
-	  sprintf(pbt,"TRACE : %s",PyString_AsString(trace));
-	else
-	  fprintf(stderr,"EMPTY TRACE ?");
-	trace=NULL;
-	trace=PyObject_Str(ptype);
-	if(PyString_Check(trace)){
-	  char *tpbt=zStrdup(pbt);
-	  sprintf(pbt,"%s\n%s",tpbt,PyString_AsString(trace));
-	  free(tpbt);
-	}
-	else
-	  fprintf(stderr,"EMPTY TRACE ?");
-	
-	char *tpbt=zStrdup(pbt);
-	pName = PyString_FromString("traceback");
-	pModule = PyImport_Import(pName);
-	pArgs = PyTuple_New(1);
-	PyTuple_SetItem(pArgs, 0, ptraceback);
-	pFunc = PyObject_GetAttrString(pModule,"format_tb");
-	pValue = PyObject_CallObject(pFunc, pArgs);
-	trace=NULL;
-	trace=PyObject_Str(pValue);
-	if(PyString_Check(trace))
-	  sprintf(pbt,"%s\nUnable to run your python process properly. Please check the following messages : %s",tpbt,PyString_AsString(trace));
-	else
-	  sprintf(pbt,"%s \n Unable to run your python process properly. Unable to provide any futher informations.",tpbt);
-	free(tpbt);
-	map* err=createMap("text",pbt);
-	addToMap(err,"code","NoApplicableCode");
-	printExceptionReportResponse(m,err);
+	PythonZooReport(m,tmp->value,0);
 	res=-1;
       }
@@ -291,16 +255,9 @@
       char tmpS[1024];
       sprintf(tmpS, "Cannot find the %s function in the %s file.\n", s->name, tmp->value);
-      map* tmps=createMap("text",tmpS);
-      printExceptionReportResponse(m,tmps);
+      errorException(m,tmpS,"NoApplicableCode",NULL);
       res=-1;
     }
   } else{
-    char tmpS[1024];
-    sprintf(tmpS, "Python module %s cannot be loaded.\n", tmp->value);
-    map* tmps=createMap("text",tmpS);
-    printExceptionReportResponse(m,tmps);
-    if (PyErr_Occurred())
-      PyErr_Print();
-    PyErr_Clear();
+    PythonZooReport(m,tmp->value,1);
     res=-1;
   } 
@@ -312,4 +269,68 @@
   Py_Finalize();
   return res;
+}
+
+void PythonZooReport(maps* m,const char* module,int load){
+  PyObject *pName, *pModule, *pFunc;
+  PyObject *ptype, *pvalue, *ptraceback,*pValue,*pArgs;
+  PyErr_Fetch(&ptype, &pvalue, &ptraceback);
+  char *pStrErrorMessage = PyString_AsString(pvalue);
+  char *tmp0=_("Python module %s cannot be loaded. Message: %s\n");
+  
+  PyObject *trace=PyObject_Str(pvalue);
+  char *pbt=NULL;
+  if(PyString_Check(trace)){
+    pbt=(char*)malloc((7+strlen(PyString_AsString(trace))+1)*sizeof(char));
+    sprintf(pbt,"TRACE: %s",PyString_AsString(trace));
+  }
+  else
+    fprintf(stderr,"EMPTY TRACE ?");
+  
+  trace=NULL;
+  
+  trace=PyObject_Str(ptype);
+  if(PyString_Check(trace)){
+    char *tpbt=zStrdup(pbt);
+    if(pbt!=NULL)
+      free(pbt);
+    pbt=(char*)malloc((1+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char));
+    sprintf(pbt,"%s\n%s",tpbt,PyString_AsString(trace));
+    free(tpbt);
+  }
+  else
+    fprintf(stderr,"EMPTY TRACE ?");
+  
+  if(ptraceback!=NULL){
+    char *tpbt=zStrdup(pbt);
+    pName = PyString_FromString("traceback");
+    pModule = PyImport_Import(pName);
+    pArgs = PyTuple_New(1);
+    PyTuple_SetItem(pArgs, 0, ptraceback);
+    pFunc = PyObject_GetAttrString(pModule,"format_tb");
+    pValue = PyObject_CallObject(pFunc, pArgs);
+    trace=NULL;
+    trace=PyObject_Str(pValue);
+    if(PyString_Check(trace)){
+      if(pbt!=NULL)
+	free(pbt);
+      pbt=(char*)malloc((90+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char));
+      sprintf(pbt,_("%s\nUnable to run your python process properly. Please check the following messages : %s"),tpbt,PyString_AsString(trace));
+    }
+    else{
+      if(pbt!=NULL)
+	free(pbt);
+      pbt=(char*)malloc((90+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char));      
+      sprintf(pbt,_("%s \n Unable to run your python process properly. Unable to provide any futher informations."),tpbt);
+    }
+    free(tpbt);
+  }
+  if(load>0){
+    char *tmpS=(char*)malloc((strlen(tmp0)+strlen(module)+strlen(pbt)+1)*sizeof(char));
+    sprintf(tmpS,tmp0,module,pbt);
+    errorException(m,tmpS,"NoApplicableCode",NULL);
+    free(tmpS);
+  }else
+    errorException(m,pbt,"NoApplicableCode",NULL);
+  free(pbt);
 }
 
Index: /trunk/zoo-project/zoo-kernel/service_internal_python.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_python.h	(revision 575)
+++ /trunk/zoo-project/zoo-kernel/service_internal_python.h	(revision 576)
@@ -45,4 +45,6 @@
 int zoo_python_support(maps**,map*,service*,maps**,maps**);
 
+void PythonZooReport(maps*,const char*,int);
+
 PyObject* PythonTranslate(PyObject*, PyObject*);
 PyObject* PythonUpdateStatus(PyObject*, PyObject*);
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 575)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 576)
@@ -609,9 +609,6 @@
 #endif
           sprintf (tmps, _("C Library can't be loaded %s"), errstr);
-          map *tmps1 = createMap ("text", tmps);
-          printExceptionReportResponse (m, tmps1);
+	  errorException(m,tmps,"InternalError",NULL);
           *eres = -1;
-          freeMap (&tmps1);
-          free (tmps1);
         }
     }
@@ -697,6 +694,5 @@
                ("Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n"),
                r_inputs->value);
-      map *tmps = createMap ("text", tmpv);
-      printExceptionReportResponse (m, tmps);
+      errorException (m, tmpv, "InternalError", NULL);
       *eres = -1;
     }
@@ -986,105 +982,57 @@
    * Check for minimum inputs
    */
+  map* err=NULL;
+  const char *vvr[]={
+    "GetCapabilities",
+    "DescribeProcess",
+    "Execute",
+    NULL
+  };
+  checkValidValue(request_inputs,&err,"Request",(const char**)vvr,1);
+  const char *vvs[]={
+    "WPS",
+    NULL
+  };
+  if(err!=NULL){
+    checkValidValue(request_inputs,&err,"service",(const char**)vvs,1);
+    printExceptionReportResponse (m, err);
+    freeMap(&err);
+    free(err);
+    if (count (request_inputs) == 1)
+      {
+	freeMap (&request_inputs);
+	free (request_inputs);
+      }
+    freeMaps (&m);
+    free (m);
+    return 1;
+  }
+  checkValidValue(request_inputs,&err,"service",(const char**)vvs,1);
+  const char *vvv[]={
+    "1.0.0",
+    NULL
+  };
   r_inputs = getMap (request_inputs, "Request");
-  if (request_inputs == NULL || r_inputs == NULL)
-    {
-      errorException (m, _("Parameter <request> was not specified"),
-                      "MissingParameterValue", "request");
-      if (count (request_inputs) == 1)
-        {
-          freeMap (&request_inputs);
-          free (request_inputs);
-        }
-      freeMaps (&m);
-      free (m);
-      return 1;
-    }
-  else
-    {
-      REQUEST = zStrdup (r_inputs->value);
-      if (strncasecmp (r_inputs->value, "GetCapabilities", 15) != 0
-          && strncasecmp (r_inputs->value, "DescribeProcess", 15) != 0
-          && strncasecmp (r_inputs->value, "Execute", 7) != 0)
-        {
-          errorException (m,
-                          _
-                          ("Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute."),
-                          "OperationNotSupported", r_inputs->value);
-          freeMaps (&m);
-          free (m);
-          free (REQUEST);
-          return 1;
-        }
-    }
-  r_inputs = NULL;
-  r_inputs = getMap (request_inputs, "Service");
-  if (r_inputs == NULLMAP)
-    {
-      errorException (m, _("Parameter <service> was not specified"),
-                      "MissingParameterValue", "service");
-      freeMaps (&m);
-      free (m);
-      free (REQUEST);
-      return 1;
-    }
-  else
-    {
-      if (strcasecmp (r_inputs->value, "WPS") != 0)
-        {
-          errorException (m,
-                          _
-                          ("Unenderstood <service> value, WPS is the only acceptable value."),
-                          "InvalidParameterValue", "service");
-          freeMaps (&m);
-          free (m);
-          free (REQUEST);
-          return 1;
-        }
-    }
-  if (strncasecmp (REQUEST, "GetCapabilities", 15) != 0)
-    {
-      r_inputs = getMap (request_inputs, "Version");
-      if (r_inputs == NULL)
-        {
-          errorException (m, _("Parameter <version> was not specified"),
-                          "MissingParameterValue", "version");
-          freeMaps (&m);
-          free (m);
-          free (REQUEST);
-          return 1;
-        }
-      else
-        {
-          if (strcasecmp (r_inputs->value, "1.0.0") != 0)
-            {
-              errorException (m,
-                              _
-                              ("Unenderstood <version> value, 1.0.0 is the only acceptable value."),
-                              "InvalidParameterValue", "service");
-              freeMaps (&m);
-              free (m);
-              free (REQUEST);
-              return 1;
-            }
-        }
-    }
-  else
-    {
-      r_inputs = getMap (request_inputs, "AcceptVersions");
-      if (r_inputs != NULL)
-        {
-          if (strncmp (r_inputs->value, "1.0.0", 5) != 0)
-            {
-              errorException (m,
-                              _
-                              ("Unenderstood <AcceptVersions> value, 1.0.0 is the only acceptable value."),
-                              "VersionNegotiationFailed", NULL);
-              freeMaps (&m);
-              free (m);
-              free (REQUEST);
-              return 1;
-            }
-        }
-    }
+  REQUEST = zStrdup (r_inputs->value);
+  if (strncasecmp (REQUEST, "GetCapabilities", 15) != 0){
+    checkValidValue(request_inputs,&err,"version",(const char**)vvv,1);
+    checkValidValue(request_inputs,&err,"identifier",NULL,1);
+  }else{
+    checkValidValue(request_inputs,&err,"AcceptVersions",(const char**)vvv,-1);
+  }
+  if(err!=NULL){
+    printExceptionReportResponse (m, err);
+    freeMap(&err);
+    free(err);
+    if (count (request_inputs) == 1)
+      {
+	freeMap (&request_inputs);
+	free (request_inputs);
+      }
+    free(REQUEST);
+    freeMaps (&m);
+    free (m);
+    return 1;
+  }
 
   r_inputs = getMap (request_inputs, "serviceprovider");
@@ -1093,4 +1041,5 @@
       addToMap (request_inputs, "serviceprovider", "");
     }
+
 
   maps *request_output_real_format = NULL;
@@ -1124,14 +1073,10 @@
       xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");
       r_inputs = NULL;
-      r_inputs = getMap (request_inputs, "ServiceProvider");
-      xmlNodePtr n;
-      if (r_inputs != NULL)
-        n = printGetCapabilitiesHeader (doc, r_inputs->value, m);
-      else
-        n = printGetCapabilitiesHeader (doc, "", m);
-    /**
-     * Here we need to close stdout to ensure that not supported chars 
-     * has been found in the zcfg and then printed on stdout
-     */
+      //r_inputs = getMap (request_inputs, "ServiceProvider");
+      xmlNodePtr n=printGetCapabilitiesHeader(doc,m);
+      /**
+       * Here we need to close stdout to ensure that unsupported chars 
+       * has been found in the zcfg and then printed on stdout
+       */
       int saved_stdout = dup (fileno (stdout));
       dup2 (fileno (stderr), fileno (stdout));
@@ -1159,15 +1104,4 @@
     {
       r_inputs = getMap (request_inputs, "Identifier");
-      if (r_inputs == NULL
-          || strlen (r_inputs->name) == 0 || strlen (r_inputs->value) == 0)
-        {
-          errorException (m, _("Mandatory <identifier> was not specified"),
-                          "MissingParameterValue", "identifier");
-          freeMaps (&m);
-          free (m);
-          free (REQUEST);
-          free (SERVICE_URL);
-          return 0;
-        }
 
       struct dirent *dp;
@@ -1185,16 +1119,11 @@
       if (strncasecmp (REQUEST, "DescribeProcess", 15) == 0)
         {
-      /**
-       * Loop over Identifier list
-       */
+	  /**
+	   * Loop over Identifier list
+	   */
           xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");
           r_inputs = NULL;
-          r_inputs = getMap (request_inputs, "ServiceProvider");
-
-          xmlNodePtr n;
-          if (r_inputs != NULL)
-            n = printDescribeProcessHeader (doc, r_inputs->value, m);
-          else
-            n = printDescribeProcessHeader (doc, "", m);
+	  xmlNodePtr n = printWPSHeader(doc,m,"DescribeProcess",
+					"ProcessDescriptions");
 
           r_inputs = getMap (request_inputs, "Identifier");
@@ -1460,5 +1389,5 @@
       sprintf (tmpMsg,
                _
-               ("The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),
+               ("The value for <identifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),
                r_inputs->value);
       errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
@@ -1640,247 +1569,233 @@
 #endif
       char cursor_input[40960];
-      if (r_inputs != NULL)
+      if (r_inputs != NULL){
         snprintf (cursor_input, 40960, "%s", r_inputs->value);
-      else
-        {
-          errorException (m, _("Parameter <DataInputs> was not specified"),
-                          "MissingParameterValue", "DataInputs");
-          freeMaps (&m);
-          free (m);
-          free (REQUEST);
-          free (SERVICE_URL);
-          InternetCloseHandle (&hInternet);
-          freeService (&s1);
-          free (s1);
-          return 0;
-        }
-      j = 0;
-
-    /**
-     * Put each DataInputs into the inputs_as_text array
-     */
-      char *tmp1 = zStrdup (cursor_input);
-      char *pToken;
-      pToken = strtok (cursor_input, ";");
-      if (pToken != NULL && strncasecmp (pToken, tmp1, strlen (tmp1)) == 0)
-        {
-          char *tmp2 = url_decode (tmp1);
-          snprintf (cursor_input, (strlen (tmp2) + 1) * sizeof (char), "%s",
-                    tmp2);
-          free (tmp2);
-          pToken = strtok (cursor_input, ";");
-        }
-      free (tmp1);
-
-      char **inputs_as_text = (char **) malloc (100 * sizeof (char *));
-      if (inputs_as_text == NULL)
-        {
-          return errorException (m, _("Unable to allocate memory."),
-                                 "InternalError", NULL);
-        }
-      i = 0;
-      while (pToken != NULL)
-        {
-#ifdef DEBUG
-          fprintf (stderr, "***%s***\n", pToken);
-#endif
-          fflush (stderr);
-#ifdef DEBUG
-          fprintf (stderr, "***%s***\n", pToken);
-#endif
-          inputs_as_text[i] =
-            (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
-          snprintf (inputs_as_text[i], strlen (pToken) + 1, "%s", pToken);
-          if (inputs_as_text[i] == NULL)
-            {
-              return errorException (m, _("Unable to allocate memory."),
-                                     "InternalError", NULL);
-            }
-          pToken = strtok (NULL, ";");
-          i++;
-        }
-
-      for (j = 0; j < i; j++)
-        {
-          char *tmp = zStrdup (inputs_as_text[j]);
-          free (inputs_as_text[j]);
-          char *tmpc;
-          tmpc = strtok (tmp, "@");
-          while (tmpc != NULL)
-            {
-#ifdef DEBUG
-              fprintf (stderr, "***\n***%s***\n", tmpc);
-#endif
-              char *tmpv = strstr (tmpc, "=");
-              char tmpn[256];
-              memset (tmpn, 0, 256);
-              if (tmpv != NULL)
-                {
-                  strncpy (tmpn, tmpc,
-                           (strlen (tmpc) - strlen (tmpv)) * sizeof (char));
-                  tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
-                }
-              else
-                {
-                  strncpy (tmpn, tmpc, strlen (tmpc) * sizeof (char));
-                  tmpn[strlen (tmpc)] = 0;
-                }
-#ifdef DEBUG
-              fprintf (stderr, "***\n*** %s = %s ***\n", tmpn, tmpv + 1);
-#endif
-              if (tmpmaps == NULL)
-                {
-                  tmpmaps = (maps *) malloc (MAPS_SIZE);
-                  if (tmpmaps == NULL)
-                    {
-                      return errorException (m,
-                                             _("Unable to allocate memory."),
-                                             "InternalError", NULL);
-                    }
-                  tmpmaps->name = zStrdup (tmpn);
-                  if (tmpv != NULL)
-                    {
-                      char *tmpvf = url_decode (tmpv + 1);
-                      tmpmaps->content = createMap ("value", tmpvf);
-                      free (tmpvf);
-                    }
-                  else
-                    tmpmaps->content = createMap ("value", "Reference");
-                  tmpmaps->next = NULL;
-                }
-              tmpc = strtok (NULL, "@");
-              while (tmpc != NULL)
-                {
-#ifdef DEBUG
-                  fprintf (stderr, "*** KVP NON URL-ENCODED \n***%s***\n",
-                           tmpc);
-#endif
-                  char *tmpv1 = strstr (tmpc, "=");
-#ifdef DEBUG
-                  fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
-                           tmpv1 + 1);
-#endif
-                  char tmpn1[1024];
-                  memset (tmpn1, 0, 1024);
-                  if (tmpv1 != NULL)
-                    {
-                      strncpy (tmpn1, tmpc, strlen (tmpc) - strlen (tmpv1));
-                      tmpn1[strlen (tmpc) - strlen (tmpv1)] = 0;
-                      addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
-                    }
-                  else
-                    {
-                      strncpy (tmpn1, tmpc, strlen (tmpc));
-                      tmpn1[strlen (tmpc)] = 0;
-                      map *lmap = getLastMap (tmpmaps->content);
-                      char *tmpValue =
-                        (char *) malloc ((strlen (tmpv) + strlen (tmpc) + 1) *
-                                         sizeof (char));
-                      sprintf (tmpValue, "%s@%s", tmpv + 1, tmpc);
-                      free (lmap->value);
-                      lmap->value = zStrdup (tmpValue);
-                      free (tmpValue);
-                      tmpc = strtok (NULL, "@");
-                      continue;
-                    }
-#ifdef DEBUG
-                  fprintf (stderr, "*** NAME NON URL-ENCODED \n***%s***\n",
-                           tmpn1);
-                  fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
-                           tmpv1 + 1);
-#endif
-                  if (strcmp (tmpn1, "xlink:href") != 0)
-                    addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
-                  else if (tmpv1 != NULL)
-                    {
-                      char *tmpx2 = url_decode (tmpv1 + 1);
-                      if (strncasecmp (tmpx2, "http://", 7) != 0 &&
-                          strncasecmp (tmpx2, "ftp://", 6) != 0 &&
-                          strncasecmp (tmpx2, "https://", 8) != 0)
-                        {
-                          char emsg[1024];
-                          sprintf (emsg,
-                                   _
-                                   ("Unable to find a valid protocol to download the remote file %s"),
-                                   tmpv1 + 1);
-                          errorException (m, emsg, "InternalError", NULL);
-                          freeMaps (&m);
-                          free (m);
-                          free (REQUEST);
-                          free (SERVICE_URL);
-                          InternetCloseHandle (&hInternet);
-                          freeService (&s1);
-                          free (s1);
-                          return 0;
-                        }
-#ifdef DEBUG
-                      fprintf (stderr,
-                               "REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",
-                               tmpv1 + 1);
-#endif
-                      addToMap (tmpmaps->content, tmpn1, tmpx2);
+	j = 0;
+
+	/**
+	 * Put each DataInputs into the inputs_as_text array
+	 */
+	char *tmp1 = zStrdup (cursor_input);
+	char *pToken;
+	pToken = strtok (cursor_input, ";");
+	if (pToken != NULL && strncasecmp (pToken, tmp1, strlen (tmp1)) == 0)
+	  {
+	    char *tmp2 = url_decode (tmp1);
+	    snprintf (cursor_input, (strlen (tmp2) + 1) * sizeof (char), "%s",
+		      tmp2);
+	    free (tmp2);
+	    pToken = strtok (cursor_input, ";");
+	  }
+	free (tmp1);
+	
+	char **inputs_as_text = (char **) malloc (100 * sizeof (char *));
+	if (inputs_as_text == NULL)
+	  {
+	    return errorException (m, _("Unable to allocate memory."),
+				   "InternalError", NULL);
+	  }
+	i = 0;
+	while (pToken != NULL)
+	  {
+#ifdef DEBUG
+	    fprintf (stderr, "***%s***\n", pToken);
+	    fflush (stderr);
+	    fprintf (stderr, "***%s***\n", pToken);
+#endif
+	    inputs_as_text[i] =
+	      (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
+	    if (inputs_as_text[i] == NULL)
+	      {
+		return errorException (m, _("Unable to allocate memory."),
+				       "InternalError", NULL);
+	      }
+	    snprintf (inputs_as_text[i], strlen (pToken) + 1, "%s", pToken);
+	    pToken = strtok (NULL, ";");
+	    i++;
+	  }
+	
+	for (j = 0; j < i; j++)
+	  {
+	    char *tmp = zStrdup (inputs_as_text[j]);
+	    free (inputs_as_text[j]);
+	    char *tmpc;
+	    tmpc = strtok (tmp, "@");
+	    while (tmpc != NULL)
+	      {
+#ifdef DEBUG
+		fprintf (stderr, "***\n***%s***\n", tmpc);
+#endif
+		char *tmpv = strstr (tmpc, "=");
+		char tmpn[256];
+		memset (tmpn, 0, 256);
+		if (tmpv != NULL)
+		  {
+		    strncpy (tmpn, tmpc,
+			     (strlen (tmpc) - strlen (tmpv)) * sizeof (char));
+		    tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
+		  }
+		else
+		  {
+		    strncpy (tmpn, tmpc, strlen (tmpc) * sizeof (char));
+		    tmpn[strlen (tmpc)] = 0;
+		  }
+#ifdef DEBUG
+		fprintf (stderr, "***\n*** %s = %s ***\n", tmpn, tmpv + 1);
+#endif
+		if (tmpmaps == NULL)
+		  {
+		    tmpmaps = (maps *) malloc (MAPS_SIZE);
+		    if (tmpmaps == NULL)
+		      {
+			return errorException (m,
+					       _("Unable to allocate memory."),
+					       "InternalError", NULL);
+		      }
+		    tmpmaps->name = zStrdup (tmpn);
+		    if (tmpv != NULL)
+		      {
+			char *tmpvf = url_decode (tmpv + 1);
+			tmpmaps->content = createMap ("value", tmpvf);
+			free (tmpvf);
+		      }
+		    else
+		      tmpmaps->content = createMap ("value", "Reference");
+		    tmpmaps->next = NULL;
+		  }
+		tmpc = strtok (NULL, "@");
+		while (tmpc != NULL)
+		  {
+#ifdef DEBUG
+		    fprintf (stderr, "*** KVP NON URL-ENCODED \n***%s***\n",
+			     tmpc);
+#endif
+		    char *tmpv1 = strstr (tmpc, "=");
+#ifdef DEBUG
+		    fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
+			     tmpv1 + 1);
+#endif
+		    char tmpn1[1024];
+		    memset (tmpn1, 0, 1024);
+		    if (tmpv1 != NULL)
+		      {
+			strncpy (tmpn1, tmpc, strlen (tmpc) - strlen (tmpv1));
+			tmpn1[strlen (tmpc) - strlen (tmpv1)] = 0;
+			addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
+		      }
+		    else
+		      {
+			strncpy (tmpn1, tmpc, strlen (tmpc));
+			tmpn1[strlen (tmpc)] = 0;
+			map *lmap = getLastMap (tmpmaps->content);
+			char *tmpValue =
+			  (char *) malloc ((strlen (tmpv) + strlen (tmpc) + 1) *
+					   sizeof (char));
+			sprintf (tmpValue, "%s@%s", tmpv + 1, tmpc);
+			free (lmap->value);
+			lmap->value = zStrdup (tmpValue);
+			free (tmpValue);
+			tmpc = strtok (NULL, "@");
+			continue;
+		      }
+#ifdef DEBUG
+		    fprintf (stderr, "*** NAME NON URL-ENCODED \n***%s***\n",
+			     tmpn1);
+		    fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
+			     tmpv1 + 1);
+#endif
+		    if (strcmp (tmpn1, "xlink:href") != 0)
+		      addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
+		    else if (tmpv1 != NULL)
+		      {
+			char *tmpx2 = url_decode (tmpv1 + 1);
+			if (strncasecmp (tmpx2, "http://", 7) != 0 &&
+			    strncasecmp (tmpx2, "ftp://", 6) != 0 &&
+			    strncasecmp (tmpx2, "https://", 8) != 0)
+			  {
+			    char emsg[1024];
+			    sprintf (emsg,
+				     _
+				     ("Unable to find a valid protocol to download the remote file %s"),
+				     tmpv1 + 1);
+			    errorException (m, emsg, "InternalError", NULL);
+			    freeMaps (&m);
+			    free (m);
+			    free (REQUEST);
+			    free (SERVICE_URL);
+			    InternetCloseHandle (&hInternet);
+			    freeService (&s1);
+			    free (s1);
+			    return 0;
+			  }
+#ifdef DEBUG
+			fprintf (stderr,
+				 "REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",
+				 tmpv1 + 1);
+#endif
+			addToMap (tmpmaps->content, tmpn1, tmpx2);
 #ifndef WIN32
-                      if (CHECK_INET_HANDLE (hInternet))
-#endif
-                        {
-                          if (loadRemoteFile
-                              (&m, &tmpmaps->content, &hInternet, tmpx2) < 0)
-                            {
-                              freeMaps (&m);
-                              free (m);
-                              free (REQUEST);
-                              free (SERVICE_URL);
-                              InternetCloseHandle (&hInternet);
-                              freeService (&s1);
-                              free (s1);
-                              return 0;
-                            }
-                        }
-                      free (tmpx2);
-                      addToMap (tmpmaps->content, "Reference", tmpv1 + 1);
-                    }
-                  tmpc = strtok (NULL, "@");
-                }
-#ifdef DEBUG
-              dumpMaps (tmpmaps);
-              fflush (stderr);
-#endif
-              if (request_input_real_format == NULL)
-                request_input_real_format = dupMaps (&tmpmaps);
-              else
-                {
-                  maps *testPresence =
-                    getMaps (request_input_real_format, tmpmaps->name);
-                  if (testPresence != NULL)
-                    {
-                      elements *elem =
-                        getElements (s1->inputs, tmpmaps->name);
-                      if (elem != NULL)
-                        {
-                          if (appendMapsToMaps
-                              (m, request_input_real_format, tmpmaps,
-                               elem) < 0)
-                            {
-                              freeMaps (&m);
-                              free (m);
-                              free (REQUEST);
-                              free (SERVICE_URL);
-                              InternetCloseHandle (&hInternet);
-                              freeService (&s1);
-                              free (s1);
-                              return 0;
-                            }
-                        }
-                    }
-                  else
-                    addMapsToMaps (&request_input_real_format, tmpmaps);
-                }
-              freeMaps (&tmpmaps);
-              free (tmpmaps);
-              tmpmaps = NULL;
-              free (tmp);
-            }
-        }
-      free (inputs_as_text);
+			if (CHECK_INET_HANDLE (hInternet))
+#endif
+			  {
+			    if (loadRemoteFile
+				(&m, &tmpmaps->content, &hInternet, tmpx2) < 0)
+			      {
+				freeMaps (&m);
+				free (m);
+				free (REQUEST);
+				free (SERVICE_URL);
+				InternetCloseHandle (&hInternet);
+				freeService (&s1);
+				free (s1);
+				return 0;
+			      }
+			  }
+			free (tmpx2);
+			addToMap (tmpmaps->content, "Reference", tmpv1 + 1);
+		      }
+		    tmpc = strtok (NULL, "@");
+		  }
+#ifdef DEBUG
+		dumpMaps (tmpmaps);
+		fflush (stderr);
+#endif
+		if (request_input_real_format == NULL)
+		  request_input_real_format = dupMaps (&tmpmaps);
+		else
+		  {
+		    maps *testPresence =
+		      getMaps (request_input_real_format, tmpmaps->name);
+		    if (testPresence != NULL)
+		      {
+			elements *elem =
+			  getElements (s1->inputs, tmpmaps->name);
+			if (elem != NULL)
+			  {
+			    if (appendMapsToMaps
+				(m, request_input_real_format, tmpmaps,
+				 elem) < 0)
+			      {
+				freeMaps (&m);
+				free (m);
+				free (REQUEST);
+				free (SERVICE_URL);
+				InternetCloseHandle (&hInternet);
+				freeService (&s1);
+				free (s1);
+				return 0;
+			      }
+			  }
+		      }
+		    else
+		      addMapsToMaps (&request_input_real_format, tmpmaps);
+		  }
+		freeMaps (&tmpmaps);
+		free (tmpmaps);
+		tmpmaps = NULL;
+		free (tmp);
+	      }
+	  }
+	free (inputs_as_text);
+      }
     }
   else
@@ -2580,5 +2495,4 @@
               while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
                 cur2 = cur2->next;
-              int cur1cnt = 0;
               while (cur2 != NULL)
                 {
@@ -2928,5 +2842,8 @@
    * DataInputs and ResponseDocument / RawDataOutput
    */
-  char *dfv = addDefaultValues (&request_input_real_format, s1->inputs, m, 0);
+  map* errI=NULL;
+  dumpMaps(request_input_real_format);
+  char *dfv = addDefaultValues (&request_input_real_format, s1->inputs, m, 0,&errI);
+  dumpMaps(request_input_real_format);
   maps *ptr = request_input_real_format;
   while (ptr != NULL)
@@ -2968,27 +2885,57 @@
     }
 
+  map* errO=NULL;
   char *dfv1 =
-    addDefaultValues (&request_output_real_format, s1->outputs, m, 1);
+    addDefaultValues (&request_output_real_format, s1->outputs, m, 1,&errO);
   if (strcmp (dfv1, "") != 0 || strcmp (dfv, "") != 0)
     {
       char tmps[1024];
-      map *tmpe = createMap ("code", "MissingParameterValue");
+      map *tmpe = NULL;
       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);
-          addToMap (tmpe, "locator", dfv);
-        }
-      else if (strcmp (dfv1, "") != 0)
+	  tmpe = createMap ("code", "MissingParameterValue");
+	  int nb=0;
+	  int length=1;
+	  map* len=getMap(errI,"length");
+	  if(len!=NULL)
+	    length=atoi(len->value);
+	  for(nb=0;nb<length;nb++){
+	    map* errp=getMapArray(errI,"value",nb);
+	    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."),
+		      errp->value);
+	    setMapArray (tmpe, "locator", nb , errp->value);
+	    setMapArray (tmpe, "text", nb , tmps);
+	    setMapArray (tmpe, "code", nb , "MissingParameterValue");
+	  }
+	}
+      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);
-          addToMap (tmpe, "locator", dfv1);
-        }
-      addToMap (tmpe, "text", tmps);
+	  int ilength=0;
+	  if(tmpe==NULL)
+	    tmpe = createMap ("code", "InvalidParameterValue");
+	  else{
+	    map* len=getMap(tmpe,"length");
+	    if(len!=NULL)
+	      ilength=atoi(len->value);
+	  }
+	  int nb=0;
+	  int length=1;
+	  map* len=getMap(errO,"length");
+	  if(len!=NULL)
+	    length=atoi(len->value);
+	  for(nb=0;nb<length;nb++){
+	    map* errp=getMapArray(errO,"value",nb);
+	    snprintf (tmps, 1024,
+		      _
+		      ("The <%s> argument was specified as %s identifier but not defined in the ZOO Configuration File. Please, correct your query or the ZOO Configuration File."),
+		      errp->value,
+		      ((getMap(request_inputs,"RawDataOutput")!=NULL)?"RawDataOutput":"ResponseDocument"));
+	    setMapArray (tmpe, "locator", nb+ilength , errp->value);
+	    setMapArray (tmpe, "text", nb+ilength , tmps);
+	    setMapArray (tmpe, "code", nb+ilength , "InvalidParameterValue");
+	  }
+	}
       printExceptionReportResponse (m, tmpe);
       freeService (&s1);
@@ -3006,4 +2953,12 @@
       freeMaps (&tmpmaps);
       free (tmpmaps);
+      if(errI!=NULL){
+	freeMap(&errI);
+	free(errI);
+      }
+      if(errO!=NULL){
+	freeMap(&errO);
+	free(errO);
+      }
       return 1;
     }
