Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 584)
+++ 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;
               }
           }
