Index: /trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 586)
+++ /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 587)
@@ -3511,6 +3511,9 @@
  * @param mimeType the content mimeType 
  * @param length the content size
- */
-void addToCache(maps* conf,char* request,char* content,char* mimeType,int length){
+ * @param filepath a buffer for storing the path of the cached file; may be NULL
+ * @param max_path the size of the allocated filepath buffer  
+ */
+void addToCache(maps* conf,char* request,char* content,char* mimeType,int length, 
+                char* filepath, size_t max_path){
   map* tmp=getMapFromMaps(conf,"main","cacheDir");
   if(tmp!=NULL){
@@ -3524,9 +3527,16 @@
     FILE* fo=fopen(fname,"w+");
     if(fo==NULL){
-      fprintf (stderr, "Failed to open %s for writting: %s\n",fname, strerror(errno));
+#ifdef DEBUG		
+      fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno));
+#endif
+      filepath = NULL;	
       return;
     }
     fwrite(content,sizeof(char),length,fo);
     fclose(fo);
+	
+	if (filepath != NULL) {
+		strncpy(filepath, fname, max_path);
+	}	
 
     sprintf(fname,"%s/%s.zcm",tmp->value,md5str);
@@ -3541,4 +3551,7 @@
     free(fname);
   }
+  else {
+	  filepath = NULL;
+  }	  
 }
 
@@ -3665,5 +3678,5 @@
 	    }
 	    addToMap(content->content,sname,ltmp1);
-	    addToCache(*m,tmp1->value,fcontent,mimeType,fsize);
+	    addToCache(*m,tmp1->value,fcontent,mimeType,fsize, NULL, 0);
 	    free(fcontent);
 	    free(mimeType);
@@ -3767,5 +3780,5 @@
   addToMap(*content,"size",ltmp1);
   if(cached==NULL){
-    addToCache(*m,url,fcontent,mimeType,fsize);
+    addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0);
   }
   else{
Index: /trunk/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.h	(revision 586)
+++ /trunk/zoo-project/zoo-kernel/service_internal.h	(revision 587)
@@ -212,6 +212,6 @@
   xmlNodePtr soapEnvelope(maps*,xmlNodePtr);
   int checkForSoapEnvelope(xmlDocPtr);
-
-  void addToCache(maps*,char*,char*,char*,int);
+  
+  void addToCache(maps*,char*,char*,char*,int,char*,size_t);
   char* isInCache(maps*,char*);
   int runHttpRequests(maps**,maps**,HINTERNET*);
Index: /trunk/zoo-project/zoo-kernel/service_internal_php.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_php.c	(revision 586)
+++ /trunk/zoo-project/zoo-kernel/service_internal_php.c	(revision 587)
@@ -26,4 +26,8 @@
   #define NO_FCGI_DEFINES
 #endif
+
+#ifndef ZEND_DEBUG
+  #define ZEND_DEBUG 0
+#endif  
  
 #include "service_internal_php.h"
Index: /trunk/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 586)
+++ /trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 587)
@@ -173,8 +173,17 @@
       fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,value);
 #endif
+#ifdef WIN32
+      char* tmp = url_decode(value); 
+      if(tmpMap!=NULL)		
+        addToMap(tmpMap,*arrayStep,tmp);
+      else		
+        tmpMap=createMap(*arrayStep,tmp);
+      free(tmp);
+#else
       if(tmpMap!=NULL)
-	addToMap(tmpMap,*arrayStep,value);
+        addToMap(tmpMap,*arrayStep,value);
       else
-	tmpMap=createMap(*arrayStep,value);
+        tmpMap=createMap(*arrayStep,value);
+#endif	
       arrayStep++;
       delete[]value;
@@ -330,11 +339,17 @@
       token1=strtok_r(token,"=",&saveptr1);
       while(token1!=NULL){
-	if(name==NULL)
-	  name=zStrdup(token1);
-	else
-	  value=zStrdup(token1);
-	token1=strtok_r(NULL,"=",&saveptr1);
-      }
-      addToMap(tmpMap,name,value);
+        if(name==NULL)
+          name=zStrdup(token1);
+        else
+          value=zStrdup(token1);
+        token1=strtok_r(NULL,"=",&saveptr1);
+      }
+      //addToMap(tmpMap,name,value);
+	  /* knut: strtok(_r) ignores delimiter bytes at start and end of string; 
+	   * it will return non-empty string or NULL, e.g. "metapath=" yields value=NULL.
+	   * This modification sets value="" instead of NULL.
+	   */
+	  addToMap(tmpMap,name, value != NULL ? value : "");
+
       free(name);
       free(value);
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 586)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 587)
@@ -751,8 +751,26 @@
 
   map *tmpReq = getMap (request_inputs, "xrequest");
-  if (r_inputs2 != NULL)
+  
+  if(r_inputs2 != NULL && tmpReq != NULL) {
+	const char key[] = "rfile=";
+	char* kvp = (char*) malloc((FILENAME_MAX + strlen(key))*sizeof(char));
+	char* filepath = kvp + strlen(key);
+	strncpy(kvp, key, strlen(key));
+	addToCache(m, tmpReq->value, tmpReq->value, "text/xml", strlen(tmpReq->value), 
+	           filepath, FILENAME_MAX);				   
+    if (filepath == NULL) {
+        errorException( m, _("Unable to cache HTTP POST Execute request."), "InternalError", NULL);  
+		return;
+    }	
+	sprintf(tmp,"\"metapath=%s&%s&cgiSid=%s",
+	        r_inputs1->value,kvp,sid->value);
+    sprintf(tmpq,"metapath=%s&%s",
+	        r_inputs1->value,kvp);
+	free(kvp);		
+  }
+  else if (r_inputs2 != NULL)
     {
       sprintf (tmp,
-               "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",
+               "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s",
                r_inputs1->value, req->value, id->value, dataInputsKVP,
                r_inputs2->name, dataOutputsKVP, sid->value);
@@ -760,10 +778,10 @@
                "metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",
                r_inputs1->value, req->value, id->value, dataInputsKVP,
-               r_inputs2->name, dataOutputsKVP);
+               r_inputs2->name, dataOutputsKVP);		   
     }
   else
     {
       sprintf (tmp,
-               "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",
+               "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s",
                r_inputs1->value, req->value, id->value, dataInputsKVP,
                sid->value);
@@ -771,5 +789,5 @@
                "metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",
                r_inputs1->value, req->value, id->value, dataInputsKVP,
-               sid->value);
+               sid->value);   
     }
 
@@ -780,5 +798,5 @@
     }
   char *tmp1 = zStrdup (tmp);
-  sprintf (tmp, "\"%s\" %s \"%s\"", PROGRAMNAME, tmp1, sid->value);
+  sprintf (tmp, "\"%s\" %s \"%s\"", PROGRAMNAME, tmp1, sid->value);  
   free (dataInputsKVP);
   free (dataOutputsKVP);
@@ -794,4 +812,7 @@
   SetEnvironmentVariable ("CGISID", TEXT (sid->value));
   SetEnvironmentVariable ("QUERY_STRING", TEXT (tmpq));
+  // knut: Prevent REQUEST_METHOD=POST in background process call to cgic:main (process hangs when reading cgiIn):
+  SetEnvironmentVariable("REQUEST_METHOD", "GET");
+  
   char clen[1000];
   sprintf (clen, "%d", strlen (tmpq));
@@ -813,4 +834,10 @@
       fprintf (stderr, "CreateProcess failed (%d).\n", GetLastError ());
 #endif
+      if (tmp != NULL) {
+        free(tmp);
+      }
+      if (tmpq != NULL) {
+        free(tmpq);
+      }		
       return;
     }
@@ -818,5 +845,5 @@
     {
 #ifdef DEBUG
-      fprintf (stderr, "CreateProcess successfull (%d).\n\n\n\n",
+      fprintf (stderr, "CreateProcess successful (%d).\n\n\n\n",
                GetLastError ());
 #endif
@@ -824,4 +851,12 @@
   CloseHandle (pi.hProcess);
   CloseHandle (pi.hThread);
+  
+  if (tmp != NULL) {
+    free(tmp);
+  }
+  if (tmpq != NULL) {
+    free(tmpq);
+  }
+  
 #ifdef DEBUG
   fprintf (stderr, "CreateProcess finished !\n");
@@ -1367,4 +1402,5 @@
                              "InternalError", NULL);
     }
+
   r_inputs = getMap (request_inputs, "MetaPath");
   if (r_inputs != NULL)
@@ -2821,15 +2857,10 @@
                     while (cur1 != NULL && cur1->type != XML_ELEMENT_NODE)
                       cur1 = cur1->next;
+				  
+					if (request_output_real_format == NULL)
+					  request_output_real_format = dupMaps (&tmpmaps);
+					else
+					  addMapsToMaps (&request_output_real_format, tmpmaps);
                   }
-              }
-            if (request_output_real_format == NULL)
-              request_output_real_format = dupMaps (&tmpmaps);
-            else
-              addMapsToMaps (&request_output_real_format, tmpmaps);
-            if (tmpmaps != NULL)
-              {
-                freeMaps (&tmpmaps);
-                free (tmpmaps);
-                tmpmaps = NULL;
               }
           }
