Plugin 4: dynamic WebService Invoker

Here’s publically available plugin number 4 for Servoy (if I kept count correctly :) ).

This plugin is a Dynamic WebService Invoker. This means the following:
With the plugin, it’s possible to invoke WebServices, without having to hardcode information about the webservices into the plugin.

The invocation takes an Array as parameter and the Array can contain as many entries as a specific WebService needs (see samplecode).

The plugin also provides a function to describe the webservice for you, so you know what type of parameters the WebService needs (see sample code).

The plugin comes with a full example how to invoke and proces the result of a Dutch AdressValidation WebService (see sample code).

For more info on WebServices in general, have a look at www.xmethods.com
For more info on the example WebService used, check out: www.wagbill.com

This plugin is based on Axis 1.1 SOAP Libraby. The library is supplied with the plugin in the zipfile. Just extract the zipfile in the Servoy\Plugin directory (keep subdirectories). Please read the license file in the Servoy\Plugin\Axis directory after unzipping.

For more information on this plugin, move the samplecode on the About function.

This plugin is provided “as is” and free of charge. Feel free to ask questions, report bugs or ask for features.

Currently, the invokation needs an internet connection (to the location of the WebService) on the computer where the client runs. For a future release I’ll plan to provide a InvokeWSServer function as well.

Enjoy…

Paul

Cool stuff!
More and more services are being offered as a webservice, this is the future of server to server communication!

I have uploaded a new version (beta3), which has a bugfix for the getWSInfo function.

Beta2 whould only show one result when getting the methods for a specific WebService location, even if there were multiple methods.

This is fixed in beta3.

Paul

Hi,

Just posted RC2.

Previous versions would go into error when passing a null value as a parameter. This is fixed.

Also, the SampleCode of the getWSInfo function is more advanced. It will give you a ready-to-run method. If you fill in the URL you want to get info for, the code will let you select for which method you want it and then give you the opertunity to copy the neseccary code for invoking the method to the ClipBoard. The only thing you have to do is paste the clipboard content into a method, set the values and you’re ready to go.

Enjoy,

Paul

PS. I anticipate that I have to change the name of the plugin and the class of the plugin within 1 or 2 months :( This will mean that in your methods, you would have to update the reference.
Luckely Servoy has a Search and Replace option, making this a piece of cake :D

For example:

plugins.PBS_DynamicWSClient.InvokeWSClient(params);

would have to change into:

plugins.xxxxxxx_DynamicWSClient.InvokeWSClient(params);

When the new name is clear, I will also release a more advanced version, including Server side invocation.

I am very interested in this plugin.
Where can I download it from?

If you give me your email adres, I’ll email it to you.

Paul

Hi All,

An updated version of the Dynamic WebService invoker plugin is downloadable from the following URL:

http://downloads.servoy.com/thirdparty/ … rvices.zip

Download the zipfile and unzip it in the plugins directory of Servoy, keeping the subdirectories that are in the zipfile.

Since the previous version of the plugin, the namiing of the plugin and the functions has changed, allthough the functionality remains pretty much the same. So, if you want to upgrade to this version, you need to adjust the naming in your code.

I did add the ability to invoke the webservice through the server.

Feel free to ask questions and/or report issues. I’ll try to answer/solve them, allthough there’s no official support for the plugin.

Having said that: We have been using this plugin in our production environment for over 2 years now, without problems.

The plugin is provided free of charge and as is.

Regards,

Paul Bakker

As well as using external webservices can Servoy provide a webservice itself to broadcast content onto other websites.?

For instance by using XML_RPC or SOAP and callling a Servoy method in order to return the appropriate data as a webservice to external websites.

MerMer

I know it’s on Servoy’s ToDo list, but no idea for what version.

I’ve been playing around with it, got some basic stuff up and running, but nothing I could publish.

So, it’s doable :)

Maybe, if I get around to it one day, I’ll extend the plugin to enable methods through WebServices, but it won’t be shortly…

Paul

MerMer:
As well as using external webservices can Servoy provide a webservice itself to broadcast content onto other websites.?

For instance by using XML_RPC or SOAP and callling a Servoy method in order to return the appropriate data as a webservice to external websites.

MerMer

You can do this (or sort of) using the headless client: just call a jsp page from a browser passing parameters if you need to and receiving the result as HTML, I use this to generate a map (html table) of a wharehouse directly on servoy server (it’s faster), have a look at the jsp:

<%@ page import = "java.util.*" %> 
<%@ page import = "com.servoy.j2db.server.headlessclient.*" %> 
<%@ page import = "com.servoy.j2db.dataprocessing.IDataSet" %> 
<%@ page errorPage="errorpage.jsp" %> 
<% 
   ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy"); 
   if (servoy_hc == null) 
   { 
      servoy_hc = HeadlessClientFactory.createSessionBean(request,"SprintEngine","username","password"); 
      session.setAttribute("servoy",servoy_hc); 
   } 
   boolean ok = servoy_hc.setMainForm("Magazzino");
   
   if (!ok)
	{
		out.print("error cannot work on required form");
		return;
	}

%>
<% 
    String result="";
    
    result= (String)servoy_hc.executeMethod(null,"hcGeneraMappa",null);
    
    out.println(result);
    
    session.setAttribute("servoy", null);
%>

And here’s the method hcGeneraMappa invoked by the jsp page:

//Map init
var mappa = hcInizializzaMappa();

...
...

return mappa;

Hope you can get the idea.

As I was thinking through the problem last night the headless client occured to me and you’ve answered my next question - many thanks.

What is the performance like of the headless client? Can it scale?

MerMer

It is considerably faster than doing the same operation on a remote smart client, basically an HC is a smart client which runs directly on the server so there is no overhead due to the network. Faster the server hardware faster the headless client.
In my case I had to generate an HTML table representing a warehouse and color the cells based on the space left on the shelves (red, yellow, green), this involves a lot of sql queries to calculate the right color for each table cell. Same procedure, on remote smart client (PPC G5 dual2000): 45+ secs, on headless client (Servoy server on Dual Pentium3 1000): 8 secs.

Quite impressive, uh? :wink:

Nicola,

Impressive use of the technology. Thanks for sharing. How about scale? Could you application serve 100’s of simultaneous users?

MerMer

Scaling is a strange beast.
The map calculation involves a lot of queries to determine the cell color based on the available slots in the shelves so I think that faster hardware and a separate DB server should allow to scale without problems. Keep in mind that my DB (mysql) and Servoy server are both running on a quite old machine (Pentium3 2x1000), using two separate server like Pentium4 or whatever should allow a lot more speed in this kind of process.

To give you an idea these are the queries needed to build the map on my development machine (Dual PPC G5 2000mhz, servoy developer, mysql 4.1.14), the whole process took less than 4 seconds:

Total Time (mm:ss:ms)	Count	Avg Time (mm:ss:ms)	SQL Statement
00:01:371	1373	00:00:000	select bancali.bancaliid, bancali.id_ubicazione, bancali.data_creazione from bancali where bancali.id_ubicazione = ? order by bancali.bancaliid
00:00:687	242	00:00:002	select ubicazione.ubicazioneid from ubicazione where (ubicazione.settore = ? and ubicazione.fila = ? ) order by ubicazione.ubicazioneid
00:00:085	74	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?,?,?,?,?,?,?)
00:00:029	22	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?,?,?,?,?,?)
00:00:027	25	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?,?,?,?)
00:00:027	19	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?,?,?,?,?,?,?,?,?,?)
00:00:006	5	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
00:00:003	2	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
00:00:002	1	00:00:002	select sg.group_id,sg.group_name from servoy_groups sg,servoy_user_groups sug where sg.group_id = sug.group_id and sug.user_id = ? order by sg.group_name
00:00:002	2	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?,?)
00:00:002	1	00:00:002	select ubicazione.ubicazioneid from ubicazione order by ubicazione.ubicazioneid
00:00:001	1	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?)
00:00:001	2	00:00:000	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?)
00:00:001	1	00:00:001	select ubicazione.settore, ubicazione.ubicazioneid, ubicazione.ubicazione, ubicazione.slot, ubicazione.fila, ubicazione.livello from ubicazione where ubicazione.ubicazioneid in (?,?,?,?,?)

Great plugin, thanks!

Will this plugin work with servoy 4.0?

I’ve put an updated version on the download, which also works with Servoy 4.x

Paul

Nice !!

Thanks Paul,

Does anyone think that is possible to use the HC functionality to receive/transmit XML/SOAP requests from a handheld device (with a basic client written in J2ME)? The reason I ask is that I would like to know if it is possible to build a client (in a handheld device) that can be offline and communicate with the server when a connection is available. I know all the iPhone stuff is cool but what I have in mind needs to be able to hold data when there is no connection (wireless or otherwise).

Has anyone tried or done this or anything similar from a handheld device in Servoy? It would be nice to not have to build the server side stuff for XML/SOAP and or manipulate the backened data.

Hi full_noize,

I have a customer running HC that takes care of 2-way communication between a .Net (web)server that is in the cloud and Servoy that is on premise. Both the servers use XML to communicate and send data over using the HTTP protocol. All the logic is basically in a few methods.
So I would say it’s very possible.
Just make the JSP so that you pass the parameter(s) to a method and return back the result.
If you want I can post the simple JSP here.

Hope this helps.