Index: /trunk/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-kernel/service_internal.c	(revision 279)
+++ /trunk/zoo-kernel/service_internal.c	(revision 280)
@@ -371,4 +371,5 @@
 #endif
   int currId=-1;
+  int currNode=-1;
   if(nbNs==0){
     nbNs++;
@@ -403,4 +404,28 @@
   }
   nbNs=0;
+}
+
+xmlNodePtr soapEnvelope(maps* conf,xmlNodePtr n){
+  map* soap=getMapFromMaps(conf,"main","isSoap");
+  if(soap!=NULL && strcasecmp(soap->value,"true")==0){
+    int lNbNs=nbNs;
+    nsName[lNbNs]=strdup("soap");
+    usedNs[lNbNs]=xmlNewNs(NULL,BAD_CAST "http://www.w3.org/2003/05/soap-envelope",BAD_CAST "soap");
+    nbNs++;
+    xmlNodePtr nr = xmlNewNode(usedNs[lNbNs], BAD_CAST "Envelope");
+    nsName[nbNs]=strdup("soap");
+    usedNs[nbNs]=xmlNewNs(nr,BAD_CAST "http://www.w3.org/2003/05/soap-envelope",BAD_CAST "soap");
+    nbNs++;
+    nsName[nbNs]=strdup("xsi");
+    usedNs[nbNs]=xmlNewNs(nr,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
+    nbNs++;
+    xmlNsPtr ns_xsi=usedNs[nbNs-1];
+    xmlNewNsProp(nr,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.w3.org/2003/05/soap-envelope http://www.w3.org/2003/05/soap-envelope");
+    xmlNodePtr nr1 = xmlNewNode(usedNs[lNbNs], BAD_CAST "Body");
+    xmlAddChild(nr1,n);
+    xmlAddChild(nr,nr1);
+    return nr;
+  }else
+    return n;
 }
 
@@ -719,5 +744,6 @@
   xmlAddChild(n,nc1);
   
-  xmlDocSetRootElement(doc, n);
+  xmlNodePtr fn=soapEnvelope(m,n);
+  xmlDocSetRootElement(doc, fn);
   //xmlFreeNs(ns);
   free(SERVICE_URL);
@@ -779,5 +805,6 @@
   addLangAttr(n,m);
 
-  xmlDocSetRootElement(doc, n);
+  xmlNodePtr fn=soapEnvelope(m,n);
+  xmlDocSetRootElement(doc, fn);
 
   return n;
@@ -1007,5 +1034,9 @@
 	}
     }
+
     _tmp=e->supported;
+    if(_tmp==NULL && datatype==0)
+      _tmp=e->defaults;
+
     int hasSupported=-1;
     while(_tmp!=NULL){
@@ -1097,5 +1128,5 @@
 
 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){
-  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
+  xmlNsPtr ns,ns1,ns_ows,ns_xlink,ns_xsi;
   xmlNodePtr nr,n,nc,nc1,nc2,nc3,pseudor;
   xmlDocPtr doc;
@@ -1104,4 +1135,5 @@
   time_t time1;  
   time(&time1);
+  nr=NULL;
   /**
    * Create the document and its temporary root.
@@ -1110,6 +1142,7 @@
   int wpsId=zooXmlAddNs(NULL,"http://www.opengis.net/wps/1.0.0","wps");
   ns=usedNs[wpsId];
-  
+
   n = xmlNewNode(ns, BAD_CAST "ExecuteResponse");
+  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
   int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
   ns_ows=usedNs[owsId];
@@ -1118,6 +1151,5 @@
   int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
   ns_xsi=usedNs[xsiId];
-  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
-
+  
   xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_response.xsd");
   
@@ -1163,5 +1195,5 @@
 	sprintf(currentSid,"%s",tmp_lenv->value);
       if(tmpm==NULL || strcasecmp(tmpm->value,"false")==0){
-	sprintf(url,"%s/?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid);
+	sprintf(url,"%s?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid);
       }else{
 	if(strlen(tmpm->value)>0)
@@ -1180,5 +1212,5 @@
     }
     if(tmpm1!=NULL)
-      sprintf(tmp,"%s/",tmpm1->value);
+      sprintf(tmp,"%s",tmpm1->value);
     tmpm1=getMapFromMaps(m,"main","TmpPath");
     sprintf(stored_path,"%s/%s_%i.xml",tmpm1->value,service,pid);
@@ -1316,5 +1348,7 @@
     while(mcursor!=NULL){
       scursor=getElements(serv->outputs,mcursor->name);
-      printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output");
+      if(scursor!=NULL){
+	printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output");
+      }
       mcursor=mcursor->next;
     }
@@ -1324,5 +1358,7 @@
   fprintf(stderr,"printProcessResponse 1 202\n");
 #endif
-  xmlDocSetRootElement(doc, n);
+  nr=soapEnvelope(m,n);
+  xmlDocSetRootElement(doc, nr);
+
   if(hasStoredExecuteResponse==true){
     /* We need to write the ExecuteResponse Document somewhere */
@@ -1537,5 +1573,5 @@
 	  char tmp1[1024];
 	  sprintf(tmp1,"%d",strlen(toto->value));
-	  rs=createMap("z",tmp1);
+	  rs=createMap("size",tmp1);
 	  isSized=false;
 	}
@@ -1547,10 +1583,19 @@
 	}
       }
-      else if(tmp!=NULL){
-	if(strncmp(tmp->value,"text/js",4)==0 ||
-	   strncmp(tmp->value,"application/js",14)==0)
+      else if(tmp2!=NULL){
+	if(strncmp(tmp2->value,"text/js",7)==0 ||
+	   strncmp(tmp2->value,"application/json",16)==0)
 	  xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value)));
-	else
-	  xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
+	else{
+	  if(strncmp(tmp2->value,"text/xml",8)==0 ||
+	     strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0){
+	    xmlDocPtr doc =
+	      xmlParseMemory(BAD_CAST toto->value,strlen(BAD_CAST toto->value));
+	    xmlNodePtr ir = xmlDocGetRootElement(doc);
+	    xmlAddChild(nc3,ir);
+	  }
+	  else
+	    xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
+	}
 	xmlAddChild(nc2,nc3);
       }
@@ -1961,4 +2006,12 @@
   elements* tmpInputs=in;
   maps* out1=*out;
+  if(type==1){
+    while(out1!=NULL){
+      if(getElements(in,out1->name)==NULL)
+	return out1->name;
+      out1=out1->next;
+    }
+    out1=*out;
+  }
   while(tmpInputs!=NULL){
     maps *tmpMaps=getMaps(out1,tmpInputs->name);
@@ -2090,4 +2143,5 @@
       else
 	addToMap(tmpMaps->content,"inRequest","true");
+
     }
     tmpInputs=tmpInputs->next;
@@ -2244,2 +2298,76 @@
   
 }
+
+/**
+ * Cache a file for a given request
+ */
+void addToCache(maps* conf,char* request,char* content,int length){
+  map* tmp=getMapFromMaps(conf,"main","cacheDir");
+  if(tmp!=NULL){
+    char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+6));
+    sprintf(fname,"%s/list",tmp->value);
+    fprintf(stderr,"Cache list : %s\n",fname);
+    fflush(stderr);
+    struct stat f_status;
+    int s=stat(fname, &f_status);
+    /**
+     * If the file does not exist, create it
+     */
+    if(s<0){
+      FILE* f=fopen(fname,"w+");
+      if(f)
+	fclose(f);
+      s=stat(fname, &f_status);
+    }
+    if(f_status.st_size>=0){
+      FILE* f=fopen(fname,"a+");
+      char* foname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+64));
+      sprintf(foname,"%s/%d.zca",tmp->value,f_status.st_size);
+      fprintf(stderr,"Cache file : %s\n",foname);
+      fflush(stderr);
+      FILE* fo=fopen(foname,"w+");
+      char *fcontent=(char*)malloc(sizeof(char)*(strlen(foname)+strlen(request)+3));
+      sprintf(fcontent,"%s|%s\n",request,foname);
+
+      fwrite(fcontent,sizeof(char),strlen(fcontent),f);
+      fwrite(content,sizeof(char),length,fo);
+      fclose(f);
+      fclose(fo);
+    }
+  }
+}
+
+char* isInCache(maps* conf,char* request){
+  map* tmp=getMapFromMaps(conf,"main","cacheDir");
+  if(tmp!=NULL){
+    char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+6));
+    sprintf(fname,"%s/list",tmp->value);
+    struct stat f_status;
+    int s=stat(fname, &f_status);
+    if(s==0){
+      char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
+      FILE* f=fopen(fname,"r");
+      fread(fcontent,sizeof(char),f_status.st_size,f);
+      char *tmp,*svt;
+      tmp=strtok_r(fcontent,"\n",&svt);
+      int lin=0;
+      while(tmp!=NULL){
+	char *tmp1,*svt1;
+	tmp1=strtok_r(tmp,"|",&svt1);
+	int hv=-1;
+	while(tmp1!=NULL){
+	  fprintf(stderr,"%s %s\n",tmp1,request);
+	  if(hv>0)
+	    return tmp1;
+	  if(strcasecmp(tmp1,request)==0)
+	    hv=1;
+	  tmp1=strtok_r(NULL,"|",&svt1);
+	}
+	lin++;
+	tmp = strtok_r(NULL,"\n",&svt);
+      }
+      fclose(f);
+    }
+  }
+  return NULL;
+}
Index: /trunk/zoo-kernel/service_internal.h
===================================================================
--- /trunk/zoo-kernel/service_internal.h	(revision 279)
+++ /trunk/zoo-kernel/service_internal.h	(revision 280)
@@ -72,7 +72,9 @@
 #endif
 #include <libxml/parser.h>
+#include <libxml/xpath.h>
+
   static char* SERVICE_URL;
-  static xmlNsPtr usedNs[5];
-  static char* nsName[5];
+  static xmlNsPtr usedNs[10];
+  static char* nsName[10];
   static int nbNs=0;
 
@@ -121,4 +123,9 @@
   int errorException(maps *m, const char *message, const char *errorcode);
 
+  int checkForSoapEnvelope(xmlDocPtr);
+
+  void addToCache(maps*,char*,char*,int);
+  char* isInCache(maps*,char*);
+  
 #ifdef __cplusplus
 }
Index: /trunk/zoo-kernel/zoo_loader.c
===================================================================
--- /trunk/zoo-kernel/zoo_loader.c	(revision 279)
+++ /trunk/zoo-kernel/zoo_loader.c	(revision 280)
@@ -48,4 +48,6 @@
 }
 
+#include "service_internal.h"
+
 xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*);
 int runRequest(map*);
@@ -85,5 +87,5 @@
 #ifdef DEBUG
   fprintf (stderr, "Addr:%s\n", cgiRemoteAddr); 
-  fprintf (stderr, "RequestMethod:%s\n", cgiRequestMethod); 
+  fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,strncasecmp(cgiRequestMethod,"post",4),strncmp(cgiContentType,"text/xml",8)==0 || strncasecmp(cgiRequestMethod,"post",4)==0); 
   fprintf (stderr, "Request: %s\n", cgiQueryString);
 #endif
@@ -93,29 +95,61 @@
   if(strncmp(cgiContentType,"text/xml",8)==0 || 
      strncasecmp(cgiRequestMethod,"post",4)==0){
-    char *buffer=new char[cgiContentLength+1];
-    if(fread(buffer,1,cgiContentLength,cgiIn)){
-      buffer[cgiContentLength]=0;
-      tmpMap=createMap("request",buffer);
+    if(cgiContentLength==NULL){
+       cgiContentLength=0;
+       char *buffer=new char[2];
+       char *res=NULL;
+       int r=0;
+       while(r=fread(buffer,sizeof(char),1,cgiIn)){
+	 cgiContentLength+=r;
+	 if(res==NULL){
+	   res=(char*)malloc(1*sizeof(char));
+	   sprintf(res,"%s",buffer);
+	 }
+	 else{
+	   res=(char*)realloc(res,(cgiContentLength+1)*sizeof(char));
+	   char *tmp=strdup(res);
+	   sprintf(res,"%s%s",tmp,buffer);
+	   free(tmp);
+	 }
+       }
+       tmpMap=createMap("request",res);
     }else{
-      char **array, **arrayStep;
-      if (cgiFormEntries(&array) != cgiFormSuccess) {
-	return 1;
+      char *buffer=new char[cgiContentLength+1];
+      if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)){
+	buffer[cgiContentLength]=0;
+	tmpMap=createMap("request",buffer);
+	dumpMap(tmpMap);
+      }else{
+	buffer[0]=0;
+	char **array, **arrayStep;
+	if (cgiFormEntries(&array) != cgiFormSuccess) {
+	  return 1;
+	}
+	arrayStep = array;
+	while (*arrayStep) {
+	  char *ivalue=new char[cgiContentLength];
+	  cgiFormStringNoNewlines(*arrayStep, ivalue, cgiContentLength);
+	  char* tmpValueFinal=(char*) malloc((strlen(*arrayStep)+strlen(ivalue)+1)*sizeof(char));
+	  sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
+	  if(strlen(buffer)==0){
+	    sprintf(buffer,"%s",tmpValueFinal);
+	  }else{
+	    char *tmp=strdup(buffer);
+	    sprintf(buffer,"%s&%s",tmp,tmpValueFinal);
+	    free(tmp);
+	  }
+	  
+	  sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
+	  free(tmpValueFinal);
+#ifdef DEBUG
+	  fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,ivalue);
+#endif
+	  delete[]ivalue;
+	  arrayStep++;
+	}
+	tmpMap=createMap("request",buffer);
       }
-      arrayStep = array;
-      while (*arrayStep) {
-	char *value=new char[cgiContentLength];
-	cgiFormStringNoNewlines(*arrayStep, value, cgiContentLength);
-	char* tmpValueFinal=(char*) malloc((strlen(*arrayStep)+strlen(value)+1)*sizeof(char));
-	sprintf(tmpValueFinal,"%s=%s",*arrayStep,value);
-	tmpMap=createMap("request",tmpValueFinal);
-	free(tmpValueFinal);
-#ifdef DEBUG
-	fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,value);
-#endif
-	delete[]value;
-	arrayStep++;
-      }
+      delete[]buffer;
     }
-    delete[]buffer;
   }
   else{
@@ -162,4 +196,28 @@
       xmlInitParser();
       xmlDocPtr doc = xmlParseMemory(t1->value,cgiContentLength);
+
+
+      {
+	xmlXPathObjectPtr reqptr=extractFromDoc(doc,"/*[local-name()='Envelope']/*[local-name()='Body']/*");
+	if(reqptr!=NULL){
+	  xmlNodeSet* req=reqptr->nodesetval;
+	  if(req!=NULL && req->nodeNr==1){
+	    addToMap(tmpMap,"soap","true");
+	    int k=0;
+	    for(k;k < req->nodeNr;k++){
+	      xmlNsPtr ns=xmlNewNs(req->nodeTab[k],BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
+	      xmlDocSetRootElement(doc, req->nodeTab[k]);
+	      xmlChar *xmlbuff;
+	      int buffersize;
+	      xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, "utf-8", 1);
+	      addToMap(tmpMap,"xrequest",(char*)xmlbuff);
+	      char *tmp=(char*)xmlbuff;
+	      fprintf(stderr,"%s\n",tmp);
+	      xmlFree(xmlbuff);
+	    }
+	  }
+	}
+      }
+
       xmlNodePtr cur = xmlDocGetRootElement(doc);
       char *tval;
@@ -172,11 +230,7 @@
       if(tval!=NULL)
 	addToMap(tmpMap,"language",tval);
-      
-      const char* requests[3];
-      requests[0]="GetCapabilities";
-      requests[1]="DescribeProcess";
-      requests[2]="Execute";
+      const char* requests[3]={"GetCapabilities","DescribeProcess","Execute"};
       for(int j=0;j<3;j++){
-	char tt[35];
+	char tt[128];
 	sprintf(tt,"/*[local-name()='%s']",requests[j]);
 	xmlXPathObjectPtr reqptr=extractFromDoc(doc,tt);
Index: /trunk/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-kernel/zoo_service_loader.c	(revision 279)
+++ /trunk/zoo-kernel/zoo_service_loader.c	(revision 280)
@@ -493,4 +493,9 @@
   textdomain("zoo-services");
 
+  map* lsoap=getMap(request_inputs,"soap");
+  if(lsoap!=NULL && strcasecmp(lsoap->value,"true")==0)
+    setMapInMaps(m,"main","isSoap","true");
+  else
+    setMapInMaps(m,"main","isSoap","false");
 
   /**
@@ -1041,37 +1046,58 @@
 	      fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
 #endif
+	      char *tmpx=url_encode(tmpv1+1);
+	      addToMap(tmpmaps->content,tmpn1,tmpx);
+	      
 #ifndef WIN32
 	      if(CHECK_INET_HANDLE(hInternet))
 #endif
 		{
-		  res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,
-				      INTERNET_FLAG_NO_CACHE_WRITE,0);
-#ifdef DEBUG
-		  fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",
-			  tmpv1+1,res.nDataAlloc,res.nDataLen);
-#endif
-		  char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
-		  if(tmpContent == NULL){
-		    return errorException(m, _("Unable to allocate memory."), "InternalError");
+		  char* cached=isInCache(m,tmpv1+1);
+		  if(cached!=NULL){
+		    fprintf(stderr,"Use cached file: %s\n",cached);
+		    struct stat f_status;
+		    int s=stat(cached, &f_status);
+		    if(s==0){
+		      map* tmpMap=getMap(tmpmaps->content,"value");
+		      char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
+		      FILE* f=fopen(cached,"r");
+		      fread(fcontent,sizeof(char),f_status.st_size,f);
+		      free(tmpMap->value);
+		      tmpMap->value=(char*)malloc((f_status.st_size+1)*sizeof(char));
+		      memmove(tmpMap->value,fcontent,(f_status.st_size)*sizeof(char)); 
+		      free(fcontent);
+		    }
+		  }else{
+		    res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,
+					INTERNET_FLAG_NO_CACHE_WRITE,0);
+#ifdef DEBUG
+		    fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",
+			    tmpv1+1,res.nDataAlloc,res.nDataLen);
+#endif
+		    char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
+		    if(tmpContent == NULL){
+		      return errorException(m, _("Unable to allocate memory."), "InternalError");
+		    }
+		    size_t dwRead;
+		    InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);
+		    map* tmpMap=getMap(tmpmaps->content,"value");
+		    if(tmpMap!=NULL){
+		      free(tmpMap->value);
+		      tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));
+		      memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));
+		      tmpMap->value[res.nDataLen]=0;
+		      if(strlen(tmpContent)!=res.nDataLen){
+			char tmp[256];
+			sprintf(tmp,"%d",res.nDataLen*sizeof(char));
+			addToMap(tmpmaps->content,"size",tmp);
+		      }
+		      addToCache(m,tmpv1+1,tmpContent,res.nDataLen);
+		    }
+		    free(tmpContent);
 		  }
-		  size_t dwRead;
-		  InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);
-		  map* tmpMap=getMap(tmpmaps->content,"value");
-		  if(tmpMap!=NULL){
-		    free(tmpMap->value);
-		    tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));
-		    memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));
-		    tmpMap->value[res.nDataLen]=0;
-		    if(strlen(tmpContent)!=res.nDataLen){
-		      char tmp[256];
-		      sprintf(tmp,"%d",res.nDataLen*sizeof(char));
-		      addToMap(tmpmaps->content,"size",tmp);
-		    }
-		  }
-		  free(tmpContent);
 		}
-	      char *tmpx=url_encode(tmpv1+1);
-	      addToMap(tmpmaps->content,tmpn1,tmpx);
-	      free(tmpx);
+	      char *tmpx1=url_encode(tmpv1+1);
+	      addToMap(tmpmaps->content,tmpn1,tmpx1);
+	      free(tmpx1);
 	      addToMap(tmpmaps->content,"Reference",tmpv1+1);
 	    }
@@ -1413,10 +1439,10 @@
 		    else
 		      tmpmaps->content=createMap(list[l],(char*)val);
+#ifdef DEBUG
+		    fprintf(stderr,"%s\n",val);
+#endif
 		  }
-#ifdef DEBUG
-		  fprintf(stderr,"%s\n",val);
-#endif
 		  xmlFree(val);
-		  free(list[l]);
+		  free(list[l]);		  
 		}
 	      }
@@ -1432,5 +1458,5 @@
 		for(int l=0;l<3;l++){
 #ifdef DEBUG
-		  fprintf(stderr,"*** ComplexData %s ***",coms[l]);
+		  fprintf(stderr,"*** ComplexData %s ***\n",coms[l]);
 #endif
 		  xmlChar *val=xmlGetProp(cur4,BAD_CAST coms[l]);
@@ -1440,18 +1466,33 @@
 		    else
 		      tmpmaps->content=createMap(coms[l],(char*)val);
+#ifdef DEBUG
+		    fprintf(stderr,"%s\n",val);
+#endif
 		  }
-#ifdef DEBUG
-		  fprintf(stderr,"%s\n",val);
-#endif
 		  xmlFree(val);
 		}
 	      }
+
 	      map* test=getMap(tmpmaps->content,"encoding");
-	      if(test==NULL || strcasecmp(test->value,"base64")!=0){
+	      if(test==NULL){
+		if(tmpmaps->content!=NULL)
+		  addToMap(tmpmaps->content,"encoding","utf-8");
+		else
+		  tmpmaps->content=createMap("encoding","utf-8");
+		test=getMap(tmpmaps->content,"encoding");
+	      }
+
+	      if(strcasecmp(test->value,"base64")!=0){
 		xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1);
-		if(mv==NULL){
+		map* ltmp=getMap(tmpmaps->content,"mimeType");
+		if(mv==NULL || 
+		   (xmlStrcasecmp(cur4->name, BAD_CAST "ComplexData")==0 &&
+		    (ltmp==NULL || strncasecmp(ltmp->value,"text/xml",8)==0) )){
 		  xmlDocPtr doc1=xmlNewDoc(BAD_CAST "1.0");
 		  int buffersize;
-		  xmlDocSetRootElement(doc1,cur4->xmlChildrenNode);
+		  xmlNodePtr cur5=cur4->children;
+		  while(cur5!=NULL &&cur5->type!=XML_ELEMENT_NODE)
+		    cur5=cur5->next;
+		  xmlDocSetRootElement(doc1,cur5);
 		  xmlDocDumpFormatMemoryEnc(doc1, &mv, &buffersize, "utf-8", 1);
 		  char size[1024];
@@ -1578,5 +1619,50 @@
 	xmlNodePtr cur1=cur->children;
 	while(cur1){
-	  if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){
+	  /**
+	   * Indentifier
+	   */
+	  if(xmlStrncasecmp(cur1->name,BAD_CAST "Identifier",xmlStrlen(cur1->name))==0){
+	    xmlChar *val=
+	      xmlNodeListGetString(doc,cur1->xmlChildrenNode,1);
+	    if(tmpmaps==NULL){
+	      tmpmaps=(maps*)calloc(1,MAPS_SIZE);
+	      if(tmpmaps == NULL){
+		return errorException(m, _("Unable to allocate memory."), "InternalError");
+	      }
+	      tmpmaps->name=strdup((char*)val);
+	      tmpmaps->content=NULL;
+	      tmpmaps->next=NULL;
+	    }
+	    else
+	      tmpmaps->name=strdup((char*)val);;
+	    xmlFree(val);
+	  }
+	  /**
+	   * Title, Asbtract
+	   */
+	  else if(xmlStrncasecmp(cur1->name,BAD_CAST "Title",xmlStrlen(cur1->name))==0 ||
+		  xmlStrncasecmp(cur1->name,BAD_CAST "Abstract",xmlStrlen(cur1->name))==0){
+	    xmlChar *val=
+	      xmlNodeListGetString(doc,cur1->xmlChildrenNode,1);
+	    if(tmpmaps==NULL){
+	      tmpmaps=(maps*)calloc(1,MAPS_SIZE);
+	      if(tmpmaps == NULL){
+		return errorException(m, _("Unable to allocate memory."), "InternalError");
+	      }
+	      tmpmaps->name=strdup("missingIndetifier");
+	      tmpmaps->content=createMap((char*)cur1->name,(char*)val);
+	      tmpmaps->next=NULL;
+	    }
+	    else{
+	      if(tmpmaps->content!=NULL)
+		addToMap(tmpmaps->content,
+			 (char*)cur1->name,(char*)val);
+	      else
+		tmpmaps->content=
+		  createMap((char*)cur1->name,(char*)val);
+	    }
+	    xmlFree(val);
+	  }
+	  else if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){
 	    /**
 	     * Get every attribute from a Output node
@@ -1682,4 +1768,5 @@
   dumpMaps(request_output_real_format);
   dumpMap(request_inputs);
+  fprintf(stderr,"\n%i\n",i);
 #endif
 
@@ -1689,7 +1776,13 @@
    */
   char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,0);
-  if(strcmp(dfv,"")!=0){
+  char *dfv1=addDefaultValues(&request_output_real_format,s1->outputs,m,1);
+  if(strcmp(dfv1,"")!=0 || strcmp(dfv,"")!=0){
     char tmps[1024];
-    snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv);
+    if(strcmp(dfv,"")!=0){
+      snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv);
+    }
+    else if(strcmp(dfv1,"")!=0){
+      snprintf(tmps,1024,_("The <%s> argument was specified as Output identifier but not defined in the ZOO Configuration File. Please, correct your query or the ZOO Configuration File."),dfv1);
+    }
     map* tmpe=createMap("text",tmps);
     addToMap(tmpe,"code","MissingParameterValue");
@@ -1711,5 +1804,4 @@
     return 1;
   }
-  addDefaultValues(&request_output_real_format,s1->outputs,m,1);
 
   ensureDecodedBase64(&request_input_real_format);
@@ -1805,4 +1897,9 @@
   addToMap(_tmpMaps->content,"status","0");
   addToMap(_tmpMaps->content,"cwd",ntmp);
+  map* ltmp=getMap(request_inputs,"soap");
+  if(ltmp!=NULL)
+    addToMap(_tmpMaps->content,"soap",ltmp->value);
+  else
+    addToMap(_tmpMaps->content,"soap","false");
   if(cgiCookie!=NULL && strlen(cgiCookie)>0){
     addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1);
