# progressbar when calling web service

**URL:** <https://forum.servoy.com/t/progressbar-when-calling-web-service/15369>\
**Category:** Classic Servoy\
**Created:** [January 18, 2012, 3:36am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369 "2012-01-18T03:36:32Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogel](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@rogel](https://forum.servoy.com/u/rogel)\
**Post date:** [January 18, 2012, 3:36am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/1 "2012-01-18T03:36:32Z")

</div>

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?

```auto
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

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [January 18, 2012, 4:37am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/2 "2012-01-18T04:37:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rogel](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@rogel](https://forum.servoy.com/u/rogel)\
**Post date:** [January 18, 2012, 5:48am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/3 "2012-01-18T05:48:16Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [January 18, 2012, 6:33am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/4 "2012-01-18T06:33:47Z")

</div>

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.
> 
> ```auto
> 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);  
}

> ```auto
> 
> ```
> 
> 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();  
> }  
> }
> 
> ```auto
> 
> ```

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…

---

<div class="post-metadata">

**Author:** ![rogel](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@rogel](https://forum.servoy.com/u/rogel)\
**Post date:** [January 18, 2012, 11:18pm UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/5 "2012-01-18T23:18:46Z")

</div>

> 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.
> > 
> > ```auto
> > 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);  
}

> > ```auto
> > 
> > ```
> > 
> > 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();  
> > }  
> > }
> > 
> > ```auto
> > 
> > ```
> 
> 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?

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [January 18, 2012, 11:32pm UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/6 "2012-01-18T23:32:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rogel](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@rogel](https://forum.servoy.com/u/rogel)\
**Post date:** [January 24, 2012, 4:52am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/7 "2012-01-24T04:52:45Z")

</div>

> 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…

```auto
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

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

```

it goes to mymainsolution’s onopen method.

---

<div class="post-metadata">

**Author:** ![pogie.nocedo](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@pogie.nocedo](https://forum.servoy.com/u/pogie.nocedo)\
**Post date:** [February 7, 2012, 5:49am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/8 "2012-02-07T05:49:13Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 7, 2012, 6:00am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/9 "2012-02-07T06:00:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pogie.nocedo](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@pogie.nocedo](https://forum.servoy.com/u/pogie.nocedo)\
**Post date:** [February 14, 2012, 5:46am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/10 "2012-02-14T05:46:00Z")

</div>

> 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?

```auto
	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();

```

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 14, 2012, 11:33am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/11 "2012-02-14T11:33:40Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [February 14, 2012, 12:43pm UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/12 "2012-02-14T12:43:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pogie.nocedo](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@pogie.nocedo](https://forum.servoy.com/u/pogie.nocedo)\
**Post date:** [February 15, 2012, 6:46am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/13 "2012-02-15T06:46:44Z")

</div>

> 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)

---

<div class="post-metadata">

**Author:** ![pogie.nocedo](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@pogie.nocedo](https://forum.servoy.com/u/pogie.nocedo)\
**Post date:** [February 15, 2012, 6:51am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/14 "2012-02-15T06:51:13Z")

</div>

even if i had no exception it was not killed. ![:(]( "Sad")

---

<div class="post-metadata">

**Author:** ![pogie.nocedo](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@pogie.nocedo](https://forum.servoy.com/u/pogie.nocedo)\
**Post date:** [March 28, 2012, 1:38am UTC](https://forum.servoy.com/t/progressbar-when-calling-web-service/15369/15 "2012-03-28T01:38:47Z")

</div>

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

```auto
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?
