Making my ultra-cool Mozilla WebService IMDB query button...
I had been looking at the Mozilla Babelfish webservice query button - wondering why this extremely cool feature of Mozilla wasn't everywhere - and then I rented "The Whole 10 Yards" - which, had I checked IMDB, would have seen that this movie wasn't worth renting... It would have saved $5 and my feeling of embarrassment for the actors/actresses in this terrible movie... But I digress...
What I really want, is special glasses that overlay IMDB ratings whenever I look at a movie poster / ad / box / whatever - but until that time, I would settle for the ability to high-light movie titles at my video stores website and press a button to get the IMDB rating...
After some quick searching, I found that there was no IMDB web service - so I would have to create one - I did, however, find a very complete perl module that let me basically get a movie ranking with about 3 lines of perl code... This great library would save me a great deal of time, but would almost get me ranting about crazy software dependencies, but I'll save that for another time...
The components of my micro-project were:
(1) Something that let me get an IMDB movie rating from a movie title...
(2) Wrappering that in a web service
(3) Writing some javascript to use Mozilla's WebServiceObject...
(1) Ended up being pretty quick once I got IMDB::Film installed and running (it had 2 dependencies, which had 2 more dependencies each, but after I downloaded 10+ modules from CPAN I was laughing... thank god for CPAN or this would have taken numerous hours rather than just a single hour to get running...
(2) I was hoping to just run the webservice locally on my machine using the SOAP::Lite daemon example code - which isn't a full webserver, but something that just handles soap requests [ie - I couldn't serve my wsdl file from it] , and access it via (http://127.0.0.1/...) - but I later discovered that:
a) Mozilla and SOAP::Lite wants to get the WSDL file from a fully qualified URL, and didn't like getting things from files...
b) Mozilla checks for another file on the server which essentially allows it to make web service calls while I'm browsing other sites...
So I had created my web service using the SOAP::Lite daemon, and was able to use a SOAP::Lite client stubbed out to make calls, but Mozilla wasn't going to work, so I had to deploy to a real box, with a real webserver, etc, etc... This added a couple of unplanned hours to my task...
(3) The javascript was mostly a cut-and-paste job from Mozilla's existing example...
Long story short, I got everything working in about 6 hours... having to deploy IMDB::Film to a different machine (my laptop uses Windows, and has Perl 5.8 - Then I deployed to an old machine I had, with Perl 5.005 - had some additional dependencies, and lots of fun installation goodness...) I got my button working... Once I get a chance to make sure that the SOAP::Lite cgi isn't a security concern, I'll publish the real URL for what I have implemented...
Here's the flow of events:
Here's all of the code that makes it happen... You can't just start using this right away - I have changed the URL for my web-service so that it does not get flooded... The web service is not really at www.XYZ.com ....
This is the WSDL - basically - one method: getRating(movieTitle) - returns a single string containing "movie title:year:rating":
This is the web service code - cut and paste job from the Perl SOAP::Lite example code...
Here's the perl module... Note that it relies on the terrific IMDB::Film module...
Here's the page w/ javascript
Takes about 10 seconds to respond to the first movie query, seems faster afterwards (the javascript uses the existing web service proxy object...) I can have several queries going at once ... As a general rule, I don't rent movies with IMDB ratings under 5.0... Make donations of saved money to your favourite local charity... :)