Index: branches/branch-1.2/zoo-services/ogr/base-vect-ops/service.c
===================================================================
--- branches/branch-1.2/zoo-services/ogr/base-vect-ops/service.c	(revision 111)
+++ branches/branch-1.2/zoo-services/ogr/base-vect-ops/service.c	(revision 217)
@@ -43,5 +43,5 @@
 
   void printExceptionReportResponse(maps*,map*);
-  char *base64(const unsigned char *input, int length);
+  char *base64(const char *input, int length);
 
   OGRGeometryH createGeometryFromGML(maps* conf,char* inputStr){
@@ -56,8 +56,7 @@
     xpathObj = xmlXPathEvalExpression(BAD_CAST xpathExpr,xpathCtx);
     if(!xpathObj->nodesetval){
-      map* tmp=createMap("text","Unable to parse Input Polygon");
-      addToMap(tmp,"code","InvalidParameterValue");
-      printExceptionReportResponse(conf,tmp);
-      exit(0);
+      setMapInMaps(conf,"lenv","message",_ss("Unable to parse Input Polygon"));
+      setMapInMaps(conf,"lenv","code","InvalidParameterValue");
+      return NULL;
     }
     int size = (xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0;
@@ -80,5 +79,7 @@
     xmlFreeDoc(doc);
     xmlFreeDoc(ndoc);
+#ifndef WIN32
     xmlCleanupParser();
+#endif
 #ifdef DEBUG
     fprintf(stderr,"\nService internal print\n Loading the geometry from GML string ...");
@@ -94,4 +95,7 @@
   }
 
+#ifdef WIN32
+  __declspec(dllexport)
+#endif
   int Simplify(maps*& conf,maps*& inputs,maps*& outputs){
     maps* cursor=inputs;
@@ -104,5 +108,7 @@
     else
       tolerance=atof(tmp0->value);
+#ifdef DEBUG
     fprintf(stderr,"Tolerance for Simplify %f",tolerance);
+#endif
     map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
     if(!tmp){
@@ -126,8 +132,10 @@
       return SERVICE_FAILED;
     }
+#ifdef DEBUG
     fprintf(stderr,"Create GEOSGeometry object");
+#endif
     GEOSGeometry* ggeometry=((OGRGeometry *) geometry)->exportToGEOS();
     GEOSGeometry* gres=GEOSTopologyPreserveSimplify(ggeometry,tolerance);
-    res=OGRGeometryFactory::createFromGEOS(gres);
+    res=(OGRGeometryH)OGRGeometryFactory::createFromGEOS(gres);
     tmp1=getMapFromMaps(outputs,"Result","mimeType");
     if(tmp1!=NULL){
@@ -136,22 +144,28 @@
 	char *tmpS=OGR_G_ExportToJson(res);
 	setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
 	setMapInMaps(outputs,"Result","mimeType","text/plain");
 	setMapInMaps(outputs,"Result","encoding","UTF-8");
 	free(tmpS);
+#endif
       }
       else{
 	char *tmpS=OGR_G_ExportToGML(res);
 	setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
 	setMapInMaps(outputs,"Result","mimeType","text/xml");
 	setMapInMaps(outputs,"Result","encoding","UTF-8");
 	setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
 	free(tmpS);
+#endif
       }
     }else{
-      char *tmpS=OGR_G_ExportToJson(tmp->value);
+      char *tmpS=OGR_G_ExportToJson(res);
       setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
       setMapInMaps(outputs,"Result","mimeType","text/plain");
       setMapInMaps(outputs,"Result","encoding","UTF-8");
       free(tmpS);
+#endif
     }
     outputs->next=NULL;
@@ -178,11 +192,15 @@
       return SERVICE_FAILED;
     }
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMaps(inputs);
     fprintf(stderr,"/Service internal print \n");
+#endif
     map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMap(tmp1);
     fprintf(stderr,"/Service internal print \n");
+#endif
     if(tmp1!=NULL){
       if(strncmp(tmp1->value,"text/js",7)==0 ||
@@ -199,11 +217,15 @@
     }
     res=(*myFunc)(geometry);
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMaps(outputs);
     fprintf(stderr,"/Service internal print \n");
+#endif
     map *tmp_2=getMapFromMaps(outputs,"Result","mimeType");
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMap(tmp_2);
     fprintf(stderr,"/Service internal print \n");
+#endif
     if(tmp_2!=NULL){
       if(strncmp(tmp_2->value,"text/js",7)==0 ||
@@ -211,24 +233,30 @@
 	char *tmpS=OGR_G_ExportToJson(res);
 	setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
 	setMapInMaps(outputs,"Result","mimeType","text/plain");
 	setMapInMaps(outputs,"Result","encoding","UTF-8");
 	free(tmpS);
+#endif
       }
       else{
 	char *tmpS=OGR_G_ExportToGML(res);
 	setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
 	setMapInMaps(outputs,"Result","mimeType","text/xml");
 	setMapInMaps(outputs,"Result","encoding","UTF-8");
 	setMapInMaps(outputs,"Result","schema",schema);
 	free(tmpS);
+#endif
       }
     }else{
       char *tmpS=OGR_G_ExportToJson(res);
       setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
       setMapInMaps(outputs,"Result","mimeType","text/plain");
       setMapInMaps(outputs,"Result","encoding","UTF-8");
       free(tmpS);
-    }
-    outputs->next=NULL;
+#endif
+    }
+    //outputs->next=NULL;
 #ifdef DEBUG
     dumpMaps(outputs);
@@ -239,7 +267,9 @@
     //CPLFree(res);
     //CPLFree(geometry);
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMaps(outputs);
     fprintf(stderr,"/Service internal print \n");
+#endif
     return SERVICE_SUCCEEDED;
   }
@@ -276,21 +306,29 @@
      bufferDistance=atof(tmp->value);
    res=OGR_G_Buffer(geometry,bufferDistance,30);
+   dumpMap(tmp);
    tmp1=getMapFromMaps(outputs,"Result","mimeType");
+   dumpMap(tmp);
    if(strncmp(tmp1->value,"application/json",16)==0){
      char *tmpS=OGR_G_ExportToJson(res);
      setMapInMaps(outputs,"Result","value",tmpS);
+     dumpMap(tmp);
+#ifndef WIN32
      setMapInMaps(outputs,"Result","mimeType","text/plain");
      setMapInMaps(outputs,"Result","encoding","UTF-8");
      free(tmpS);
+#endif
    }
    else{
      char *tmpS=OGR_G_ExportToGML(res);
      setMapInMaps(outputs,"Result","value",tmpS);
+     dumpMap(tmp);
+#ifndef WIN32
      free(tmpS);
      setMapInMaps(outputs,"Result","mimeType","text/xml");
      setMapInMaps(outputs,"Result","encoding","UTF-8");
      setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
+#endif
    }
-   outputs->next=NULL;
+   //outputs->next=NULL;
    OGR_G_DestroyGeometry(geometry);
    OGR_G_DestroyGeometry(res);
@@ -335,8 +373,8 @@
     fprintf(stderr,"\nService internal print1\n");
     fflush(stderr);
-#endif
     fprintf(stderr,"\nService internal print1\n");
     dumpMaps(inputs);
     fprintf(stderr,"\nService internal print1\n");
+#endif
 
     maps* cursor=inputs;
@@ -357,24 +395,32 @@
     if(geometry1==NULL){
       setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity1."));
+#ifdef DEBUG
       fprintf(stderr,"SERVICE FAILED !\n");
-      return SERVICE_FAILED;
-    }
+#endif
+      return SERVICE_FAILED;
+    }
+#ifdef DEBUG
     fprintf(stderr,"\nService internal print1 InputEntity1\n");
+#endif
     {
       map* tmp=getMapFromMaps(inputs,"InputEntity2","value");
       map* tmp1=getMapFromMaps(inputs,"InputEntity2","mimeType");
-      //#ifdef DEBUG
+#ifdef DEBUG
       fprintf(stderr,"MY MAP \n[%s] - %i\n",tmp1->value,strncmp(tmp1->value,"application/json",16));
       //dumpMap(tmp);
       fprintf(stderr,"MY MAP\n");
-      ///#endif
       fprintf(stderr,"\nService internal print1 InputEntity2\n");
+#endif
       if(tmp1!=NULL){
         if(strncmp(tmp1->value,"application/json",16)==0){
+#ifdef DEBUG
 	  fprintf(stderr,"\nService internal print1 InputEntity2 as JSON\n");
+#endif
       	  geometry2=OGR_G_CreateGeometryFromJson(tmp->value);
 	}
 	else{
+#ifdef DEBUG
 	  fprintf(stderr,"\nService internal print1 InputEntity2 as GML\n");
+#endif
 	  geometry2=createGeometryFromGML(conf,tmp->value);
 	}
@@ -382,16 +428,25 @@
       else
       	geometry2=createGeometryFromGML(conf,tmp->value);
+#ifdef DEBUG
       fprintf(stderr,"\nService internal print1 InputEntity2 PreFinal\n");
-    }
+#endif
+    }
+#ifdef DEBUG
     fprintf(stderr,"\nService internal print1 InputEntity2 Final\n");
+#endif
     if(geometry2==NULL){
       setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity2."));
+#ifdef DEBUG
       fprintf(stderr,"SERVICE FAILED !\n");
-      return SERVICE_FAILED;
-    }
+#endif
+      return SERVICE_FAILED;
+    }
+#ifdef DEBUG
     fprintf(stderr,"\nService internal print1\n");
+#endif
     res=(*myFunc)(geometry1,geometry2);
+#ifdef DEBUG
     fprintf(stderr,"\nService internal print1\n");
-    
+#endif    
     /* nuova parte */
     map* tmp2=getMapFromMaps(outputs,"Result","mimeType");
@@ -399,15 +454,19 @@
       char *tmpS=OGR_G_ExportToJson(res);
       setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
       setMapInMaps(outputs,"Result","mimeType","text/plain");
       setMapInMaps(outputs,"Result","encoding","UTF-8");
       free(tmpS);
+#endif
     }
     else{
       char *tmpS=OGR_G_ExportToGML(res);
       setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
       setMapInMaps(outputs,"Result","mimeType","text/xml");
       setMapInMaps(outputs,"Result","encoding","UTF-8");
       setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
       free(tmpS);
+#endif
     }
     
