Geertjan is a DZone Zone Leader and has posted 457 posts at DZone. You can read more from them at their website. View Full User Profile

Open Sourced Gateway to Zembly Web Services

06.01.2009
| 4052 views |
  • submit to reddit

Zembly, Sun's Wiki-like application development environment, now exposes a web gateway, in the form of an API. Through the API, applications in JavaFX, Java SE, and Java EE can access Zembly's web services.

The Zembly client library (ZCL)  is open sourced and can be accessed from Kenai:

http://kenai.com/projects/zcl/pages/Home

A Getting Started document can be found there (with a full blown NetBeans tutorial here), as well as a set of samples, for Java applications, as well as for JavaFX applications:

What's interesting is that you use Zembly itself to generate a code snippet that accesses the web service you want to use. Below is part of a page in Zembly that I stepped through to obtain a snippet letting me access the Google translation service:

Then you can do something like this to access the given service from your Java code:

public static String translate(String q, String l, String f) {
try {
String result = Zembly.getInstance().callService(
"google.language.translate",
new String[][]{
{"langpair", l},
{"q", q},
{"format", null}});
System.out.println("result: " + result);
return result;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

One of the samples made available on the Kenai site takes this a few steps further by providing a GUI that calls the above translation method:

Here's the sample source structure:

The benefit of the API is that services created in Zembly are now very simple to access externally. You could continue accessing them as before (described in my blog), by parsing a URL, but that's a pretty clunky solution. So, the Web Gateway API exposed by Zembly gives you simple and direct access to your web services... outside of Zembly. One might imagine one group of developers creating the services, while another group works on their UIs, particularly in the declarative style provided by JavaFX.

Plus, the fact that ZCL is open source implies that you're welcome to contribute to it. More on the topic of access to Zembly services can be found in the Zembly blog.

 

AttachmentSize
google-translator.png15.07 KB
google-translator2.png34.62 KB
google-translator-3.png24.98 KB
flickerfx.png29.46 KB
google-translator.png16.38 KB
Published at DZone with permission of its author, Geertjan Wielenga.