bug fixes to invoker
diff --git a/invoker/init.sh b/invoker/init.sh
old mode 100644
new mode 100755
index 4443d7d..4cb5a50
--- a/invoker/init.sh
+++ b/invoker/init.sh
@@ -1,4 +1,4 @@
 #!/bin/bash
 
-wsk package create owdbg -p broker "https://owdb.mybluemix.net" -p action ""
+wsk package create owdbg -p broker "https://owdbg.mybluemix.net" -p action ""
 wsk action create owdbg/invoker owdbg-invoker.js
diff --git a/invoker/owdbg-invoker.js b/invoker/owdbg-invoker.js
index 85c624f..920e067 100644
--- a/invoker/owdbg-invoker.js
+++ b/invoker/owdbg-invoker.js
@@ -1,7 +1,67 @@
+var request = require('request');
+
 function main(params) {
-    request({
-	url: params.broker + "/invoke",
-	json: true,
-	body: params
+    return new Promise(function(resolve, reject) {
+	console.log('Invoking ' + JSON.stringify(params) + ' ' + JSON.stringify(whisk));
+
+	var opts = {
+	    url: params.broker + '/invoke/begin',
+	    method: 'POST',
+	    headers: {
+		'Accept': 'application/json'
+	    },
+	    json: true,
+	    body: {
+		key: whisk.getAuthKey(),
+		action: params.action,
+		namespace: params.namespace,
+		params: params
+	    }
+	};
+
+	console.log('with options ' + JSON.stringify(opts));
+	
+	request(opts, function(err, response, body) {
+	    if (err || response.statusCode != 200) {
+		if (err) console.log('OOPS1 ' + JSON.stringify(err));
+		else console.log('OOPS1b ' + JSON.stringify(response) + ' ' + JSON.stringify(body));
+		reject(body);
+	    } else {
+		console.log('YUMMO ' + body);
+		var activationId = body.activationId;
+
+		console.log('Ok, so far so good with activationId ' + activationId);
+		var timer = setInterval(function() {
+		    request({
+			url: params.broker + '/invoke/status/' + activationId,
+			method: 'GET',
+			headers: {
+			    'Accept': 'application/json',
+			    'Content-Type': 'application/json',
+			    'AuthKey': whisk.getAuthKey()
+			},
+		    }, function(err, response, body) {
+			if (err || response.statusCode != 200) {
+			    if (err) console.log('OOPS2 ' + JSON.stringify(err));
+			    else console.log('OOPS2b ' + JSON.stringify(response));
+			    reject(body);
+			} else {
+			    try {
+				body = JSON.parse(body);
+				console.log("Result? " + body.result + " " + body);
+				if (body.result !== undefined) {
+				    clearInterval(timer);
+				    resolve(body);
+				}
+			    } catch (e) {
+				console.log("Could not parse result");
+				reject(body);
+			    }
+			}
+		    }); 
+		}, 1000);
+	    }
+	});
     });
 }
+//main({'broker':'https://owdbg.mybluemix.net','action':'foo/bar15'})