Friday, August 20, 2004

Cool Web Service functions in Mozilla...

This Mozilla WSDL Example page shows how cool Mozilla can be... There is an on page example in which I can type some text, press a button, and it uses the BabelFish web service on xmethods to translate the text... Neat trick you say... This is cooler than you think because it's using Mozilla's built in web service functionality to make the request - There is no server side interface to xmethods... The browser is acting as a web service client to the babel fish service...

So that's nice and all - but the truly cool thing: There are links at the bottom of the page that I can drag onto my Mozilla toolbar (with my bookmarks...) ... I can then simply select some text on a page, and press the "bookmark" which translates the text I've highlighted! What's going on... Well the link that I dragged to my toolbar is some javascript:

var proxy= null;
var wsdl_uri = "";
function Translate (aValue) {
if (!proxy) {
var listener = {
onLoad: function (aProxy) {
proxy = aProxy;
onError: function (aError) { },
BabelFishCallback : function (aTranslatedValue) { alert(aTranslatedValue); }
} else {
function createProxy(aCreationListener) {
try {
var factory = new WebServiceProxyFactory();
factory.createProxyAsync(wsdl_uri, "BabelFishPort", "", true, aCreationListener);
} catch (ex) { alert(ex); }
function requestTranslation (value) {
if (proxy) {
proxy.BabelFish("en_fr", value);
} else {
alert("Error: Proxy set up not complete!");

else alert("please select a text before");void(0);

This is interesting on about 3 different levels:
1) I can execute javascript in Mozilla by clicking a bookmark in my toolbar...
2) This bit of code is truly interesting:

try {
var factory = new WebServiceProxyFactory();
factory.createProxyAsync(wsdl_uri, "BabelFishPort", "", true, aCreationListener);
} catch (ex) { alert(ex); }

I can now write javascript to more or less call any webservice I like (haven't tried it with complex data structures - but who knows...)
3) Why aren't there 1000 Mozilla webservice bookmarks out there for me to drop on my toolbar...

I'll be playing around with some of this today to see if I can get my own web service running using javascript, Perl, SOAP::Lite, IMDB::Film (!!) - so that as I'm looking at my video stores website, I can just highlight movie titles and get the IMDB movie rating... Will post an update later once I've got something working...


Blogger Hi-Tech said...

Hi Chris,

You have a lotta spam comments on this post (maybe some others as well...haven't seen them all). Why don you delete them and cleanse the otherwise perfect article?


May 21, 2005 9:10 PM  
Blogger Chris said...

Thanks! For some reason I had missed regularly cleaning this article. To fight comment spam, only registered bloggers can submit comments.

May 22, 2005 9:41 PM  
Blogger jon said...

We are trying to find good scary movie to take the kids this weekend. Good scary movie reviews are hard to find

I just stumbled onto your blog while looking. Seems to happen to me a lot since I am a knowledge mooch LOL


October 02, 2005 8:02 PM  
Blogger vito said...

Hallo, bin ein wenig gesurft und fand dein blog. Ich denke du hast ein interessantes Thema hier. Auf jeden Fall werde ich dich und dein blog zu den Favoriten nehmen.

Ich habe eine Seite über computerhardware. Hier findest du alles über computerhardware und noch viel mehr !

Wenn du Zeit hast, schau doch mal vorbei ! :-)

October 03, 2005 9:40 AM  

Post a Comment

<< Home