Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 604)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 617)
@@ -31,4 +31,5 @@
 #include "zoo_amqp.h"
 #include "zoo_sql.h"
+#include "zoo_json.h"
 extern "C"
 {
@@ -275,5 +276,4 @@
 }
 
-#include "zoo_json.h"
 void
 loadServiceAndRun (maps ** myMap, service * s1, map * request_inputs,
@@ -281,26 +281,4 @@
 {
  
- json_object *obj;
- mapstojson(&obj,*myMap);
- fprintf(stderr,"myMaps: %s\n",json_object_to_json_string(obj));
-
-
-json_object *obj3;
-mapstojson(&obj3,*inputs);
-fprintf(stderr,"inputs: %s\n",json_object_to_json_string(obj3));
-
-
-json_object *obj1;
- maptojson(&obj1,request_inputs);
- fprintf(stderr,"request_inputs: %s\n",json_object_to_json_string(obj1));
-
-json_object *obj2;
-mapstojson(&obj2,*ioutputs);
-fprintf(stderr,"ioutputs: %s\n",json_object_to_json_string(obj2));
-
-
-
- fflush(stderr);
-
 
  char tmps1[1024];
@@ -309,4 +287,9 @@
   maps *request_output_real_format = *ioutputs;
   maps *request_input_real_format = *inputs;
+  map * background = NULL;
+  map * uuid = getMapFromMaps(m,"lenv","usid");
+  background = getMapFromMaps(m,"lenv","background");
+
+
   /**
    * Extract serviceType to know what kind of service should be loaded
@@ -443,5 +426,11 @@
                            ("Error occured while running the %s function: %s"),
                            s1->name, errstr);
-                  errorException (m, tmpMsg, "InternalError", NULL,out);
+
+                  if (background == NULL){
+                    errorException (m, tmpMsg, "InternalError", NULL,out);
+                  }
+                  else {
+                    /* mise a jour de la table status */
+                   }
                   free (tmpMsg);
 #ifdef DEBUG
@@ -466,9 +455,10 @@
               fflush (stderr);
 #endif
-              *eres =
+
+            *eres =
                 execute (&m, &request_input_real_format,
                          &request_output_real_format);
 #ifdef DEBUG
-              fprintf (stderr, "Function loaded and returned %d\n", eres);
+              fprintf (stderr, "Function loaded and returned %d\n", *eres);
               fflush (stderr);
 #endif
@@ -497,5 +487,10 @@
           sprintf (tmps, _("C Library can't be loaded %s"), errstr);
           map *tmps1 = createMap ("text", tmps);
-          printExceptionReportResponse (m, tmps1,out);
+          if (background == NULL){
+             printExceptionReportResponse (m, tmps1,out);
+          }
+          else {
+            /* mise a jour table status */
+           }
           *eres = -1;
           freeMap (&tmps1);
@@ -578,6 +573,11 @@
                ("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,out);
+      if (background == NULL){
+        map *tmps = createMap ("text", tmpv);
+        printExceptionReportResponse (m, tmps,out);
+      }
+      else {
+      /* mise jour table status */
+      }
       *eres = -1;
     }
@@ -3043,4 +3043,5 @@
   if (status == NULLMAP)
     {
+
       loadServiceAndRun
         (&m, s1,
@@ -3055,8 +3056,5 @@
 
     eres = SERVICE_ACCEPTED;
-    json_object * msg_jobj = json_object_new_object();
-    json_object_object_add(msg_jobj,"service_identifier",json_object_new_string(service_identifier));
-
-
+    json_object *msg_jobj = json_object_new_object();
     json_object *maps_obj;
     mapstojson(&maps_obj,m);
@@ -3076,8 +3074,13 @@
     mapstojson(&outputs_jobj,request_output_real_format);
     json_object_object_add(msg_jobj,"request_output_real_format",outputs_jobj);
-   
-    if ( (send_msg(json_object_to_json_string(msg_jobj),"application/json") != 0) || (add_status(uuid) != 0) ){     
+  
+    bind_amqp();
+
+    if ( (send_msg(json_object_to_json_string(msg_jobj),"application/json") != 0) || (add_job(uuid) != 0) ){     
         eres = SERVICE_FAILED;
     }
+    close_amqp();
+    json_object_put(msg_jobj);
+    
 
 }
