progressbar when calling web service

hi!
I have a indeterminate jprogressbar on my form then onclick of a button calls a web service. the jprogressbar seems to stop moving. how can i have it moving until i receive my response from the web service?

function processrequest(event) {
   var content = "aaa";
   var url = "xxx";
	elements.bean_progressbar.visible = true;
   var response = cmn_sendRequestToService(event, content, url);
}
function cmn_sendRequestToService(event, content, url) {
	var responseBody = null
	var client = plugins.http.createNewHttpClient();
	//Create a new request of specified type.
	var request = client.createPostRequest(url);
	application.output("content="+ content)

	request.setBodyContent(content)
	var response = request.executeRequest()
	return response;

Thanks and Regards

I suppose that’s web client, right?

The problem is that since 5.2.x (don’t remember which version exactly), Servoy updated the Wicket framework and basically there’s now only one channel back to the server that can be used at one time, which, when it comes to the plugin is a big issue: doing it like it was before, the cancel call was queued and happened after the process is totally finished. I guess that’s what is happening to you as well when you try to access a web service.

Unfortunately I have no solution to offer for this kind of usage, the limitation comes from Wicket and it’s pretty deep in the framework.

ptalbot:
I suppose that’s web client, right?

The problem is that since 5.2.x (don’t remember which version exactly), Servoy updated the Wicket framework and basically there’s now only one channel back to the server that can be used at one time, which, when it comes to the plugin is a big issue: doing it like it was before, the cancel call was queued and happened after the process is totally finished. I guess that’s what is happening to you as well when you try to access a web service.

Unfortunately I have no solution to offer for this kind of usage, the limitation comes from Wicket and it’s pretty deep in the framework.

nope. smart client in developer.

Sorry but I replied to the first version of your post wich whas showing code from the busy plugin:

rogel:
how can i have an indicator(progress or busy or hourglass) while I am calling the webservice? Furthermore, that indicator should have a cancel button that will just ignore the response of the service.

I tried the busy plugin but it does not work.

function process(event, content, url) {

var params = {
processFunction: sendRequestToService,
processArgs: [event, content, url],
message: ‘Backup in Progress’,
opacity: 0.5,
paneColor: ‘#000000’,
showCancelButton: true,
dialogName: “Backup”,
cancelButtonText: ‘Stop this!’
};
plugins.busy.block(params);
}






function sendRequestToService(event, content, url) {
var response = null;
try {
response = globals.cmn_sendRequestToService(event,content,url);
return response;
} catch (e) {
// TODO: handle exception
} finally {
plugins.busy.unblock();
}
}

Out of this context, the replied I made makes no sense. Please refrain for changing a post so much that it doesn’t ask the same question anymore, otherwise people can’t understand what you are talking about.

To reply to your new question, I would adivse using a headless client (using the headless_client plugin), so that your process happens in another thread.
Otherwise, the way you do it now the thread that is updating your progressbar is blocked, waiting for the response…

ptalbot:
Sorry but I replied to the first version of your post wich whas showing code from the busy plugin:

rogel:
how can i have an indicator(progress or busy or hourglass) while I am calling the webservice? Furthermore, that indicator should have a cancel button that will just ignore the response of the service.

I tried the busy plugin but it does not work.

function process(event, content, url) {

var params = {
processFunction: sendRequestToService,
processArgs: [event, content, url],
message: ‘Backup in Progress’,
opacity: 0.5,
paneColor: ‘#000000’,
showCancelButton: true,
dialogName: “Backup”,
cancelButtonText: ‘Stop this!’
};
plugins.busy.block(params);
}






function sendRequestToService(event, content, url) {
var response = null;
try {
response = globals.cmn_sendRequestToService(event,content,url);
return response;
} catch (e) {
// TODO: handle exception
} finally {
plugins.busy.unblock();
}
}

Out of this context, the replied I made makes no sense. Please refrain for changing a post so much that it doesn’t ask the same question anymore, otherwise people can’t understand what you are talking about.

To reply to your new question, I would adivse using a headless client (using the headless_client plugin), so that your process happens in another thread.
Otherwise, the way you do it now the thread that is updating your progressbar is blocked, waiting for the response…

Sorry about that Patrick. I should have just made a follow-up question and not edit the original question. Hope I get it right, I will create a headless client to my method the calls the service?

Yes, that’s basically it. Using a headless_client also, you wouldn’t need to block the UI. The process will happen in a background thread.

ptalbot:
Yes, that’s basically it. Using a headless_client also, you wouldn’t need to block the UI. The process will happen in a background thread.

this is my first time to use headlessclient. please bear with me.

I created a solution myheadlesssolution and created printnumbers function in globals.js of myheadlesssolution. added myheadlesssolution in the modules of mymainsolution.

on mymainsolution’s form…

function onAction_doBackup(event) {	
	// Creates a headless client that will open the given solution.
	var headlessClient = plugins.headlessclient.createClient("myheadlesssolution",null,null,null);
	headlessClient.queueMethod(null,"printnumbers",null,processReturn);
}

function processReturn() {
	application.output("client return... ");
}

when I debug in developer in the line

var headlessClient = plugins.headlessclient.createClient("myheadlesssolution",null,null,null);

it goes to mymainsolution’s onopen method.

ptalbot:
Yes, that’s basically it. Using a headless_client also, you wouldn’t need to block the UI. The process will happen in a background thread.

hi patrick! rogel here. having trouble logging in my account so i created another one.

quick question. speaking about license. my smartclient, headless_client any servoy web service will all get 1 license each?

Hi Rogel,

pogie.nocedo:
quick question. speaking about license. my smartclient, headless_client any servoy web service will all get 1 license each?

That is correct. For the duration of the session a client (any type) will use up a license from the license pool.

ROCLASI:
Hi Rogel,

pogie.nocedo:
quick question. speaking about license. my smartclient, headless_client any servoy web service will all get 1 license each?

That is correct. For the duration of the session a client (any type) will use up a license from the license pool.

Thanks Robert!

Please correct me if I am wrong, executing the executeRequest in the code below internally creates a headlessclient to call the service?

	var url = "http://x.x.x.x:8080/servoy-service/rest_ws/policy_ws/ws_policy";
	var client = plugins.http.createNewHttpClient();
	//Create a new request of specified type.
	var request = client.createPostRequest(url);
	request.setBodyContent(content);
	var response = request.executeRequest();

Hi Rogel,

The http plugin doesn’t launch/use a headless client for you. It’s just a plugin that can be used inside your client (any client type).

Robert is correct, the http plugin doesn’t trigger a Headless client, but your URL probably will (even if used from simple a browser), although it will come from the REST plugin’s pool.

ptalbot:
Robert is correct, the http plugin doesn’t trigger a Headless client, but your URL probably will (even if used from simple a browser), although it will come from the REST plugin’s pool.

ok.
I had an exception in my web service and saw this in servoy-admin clients and I do not know how to kill it from code.
Solution: backuprestore_ws. Total number of clients for this solution: 1
Client: home[x.x.x.x] (Servoy Headless Client)

even if i had no exception it was not killed. :(

I am calling a servoy webservice in my solution. After execution, it is not destroyed from the Servoy Admin “Clients”.
Here is my code:

function cmn_sendRequestToService(event, content) {
	var responseBody = null;
	var url = "http://x.x.x.x:8080/servoy-service/rest_ws/xxx_ws/ws_xxx";
	var client = plugins.http.createNewHttpClient();
	//Create a new request of specified type.
	var request = client.createPostRequest(url);
	application.output("content=" + content);

	request.setBodyContent(content)
	var response = request.executeRequest();
	
	return response;
}

In the Servoy Admin “Clients”
Solution: xxx_ws. Total number of clients for this solution: 1
Application server: Server1(x.x.x.x)
Client: Server1[x.x.x.x] (Servoy Headless Client)

Is there a destroy or kill method?