glite_gsplugin_set_timeout(glite_gsplugin_get_context(soap),to);
 
-/* FIXME: does not work, ask nykolas */
        soap->max_keep_alive = 1;       /* XXX: prevent gsoap to close connection */ 
        soap_begin(soap);
        if (soap_begin_recv(soap)) {
        )
        {
                soap_send_fault(soap);
-               return ctx->error->code;        /* XXX: shall we die on some errors? */
+               if (ctx->error) {
+                       /* XXX: shall we die on some errors? */
+                       int     err = ctx->error->code;
+                       glite_jp_clear_error(ctx);
+                       return err;
+               }
+               return 0;
        }
 
        glite_jp_run_deferred(ctx);
 
                err.desc = "No file found for this job";
                glite_jp_stack_error(ctx,&err);
                err2fault(ctx,soap);
-               glite_jp_clear_error(ctx);
+//             glite_jp_clear_error(ctx);
                return SOAP_FAULT;
        }