[ Guillaume Laforge ]


Home

CV

Projets

Weblog

Web services RPC calls over Google Talk  —  Ecrit par Guillaume

With the recent release of Google Talk, the fine chaps at Google entered the Instant Messenging market. The most clever step in that direction was their choice of protocol for their IM solution: XMPP. XMPP was popularized and standardized through the IETF by the Jabber software foundation with its famous open, secure, ad-free alternative to consumer IM services like AIM, ICQ, MSN, and Yahoo (quoted from their site).

A particular benefit of choosing an open platform is that it takes advantage of available client GUIs for instance, and moreover, it can leverage specific and standardized extensions of the XMPP protocol -- called JEPs. The Jabber foundation developed an interesting set of complementary protocol extensions by allowing custom XML payloads to be developed. And there's one JEP of interest for us today: JEP-0009. This JEP defines a method for transporting XML-RPC encoded requests and responses over Jabber/XMPP.

JiveSoftware developed a Jabber library called Smack that you can use to "speak XMPP"! They recently improved this library to support Google Talk pecularities (TLS/SSL connection). With this library, we can also build our own payloads to support JEP-0009 and to programmatically make RPC calls.

Final point to glue everything together: my brilliant friend John Wilson, who wrote the Groovy XML-RPC module, built upon the Smack library and its XML-RPC code to add XML-RPC support through Google talk! Groovy's XML-RPC is particularly easy to use to expose XML-RPC services through some clever use of closures in Groovy. That means it's now possible to do remote procedure calls through Jabber.



After all these presentations, it's high time to hack some code, isn't it? Let's create a simple echo service, which will simply echoes whatever we send to it.

Let's write the server:

import groovy.net.xmlrpc.*
import org.jivesoftware.smack.GoogleTalkConnection

def srv = new JabberRPCServer()

// here is our echo service, that's a simple closure method!
srv.echo = { return it }

// let's start the server
def serverConnection = new GoogleTalkConnection()
serverConnection.login("serverId", "serverPassword")
srv.startServer(serverConnection)

// let the server run for 60 seconds
while(true) { sleep 60*1000 }
Now that we've written the server, it's time to create our client:
import groovy.net.xmlrpc.*
import org.jivesoftware.smack.GoogleTalkConnection

// let's connect to Google Talk
def clientConnection = new GoogleTalkConnection()
clientConnection.login("clientId", "clientPassword")

// create a transparent proxy around the remote service 
def serverProxy = new JabberRPCServerProxy(clientConnection, "serverId@gmail.com")

// it's time to call our service as if we were manipulating a local object
println serverProxy.echo("Hello World!")
println serverProxy.echo(345)
Currently, the improved Groovy XML-RPC library is in CVS Head only, so if you're impatient and can't wait for a new Groovy release, you'll have to build it yourself from sources! You propably also noticed you need two GTalk buddies who've authorized each other to make this sample work.

A good question to ask yourself is "uh, well, cool, but what can I do with that?" Here's a potential use case John told me about where you could want to use Groovy's XML-RPC support over Google Talk :

Some people want to use VNC to manage their home server, however you do not want to open a port on your firewall to allow VNC access from the internet (VNC is not very secure). The VNC server will "reverse connect" to an external client. So you could run a jabber RPC server which launched the VNC server telling it to reverse connect to your external machine
I can also imagine some other use cases, like:
  • triggering Continuous Integration servers which would support Jabber's XML-RPC support
  • doing some home automation to make you house warm when you come back from work in a cold winter
  • etc.
There are many possibilities, and I'm sure others will find some clever use cases for that. I can imagine Google Talk providing some cool services as well in the future, and I'm pretty sure they will.

You may also wonder why not using raw XML-RPC or standard SOAP for these kind of services? That's another possibility, of course. It's up to you to use whatever protocol you want after all, but I thought it'd be interesting to show you how we can leverage Google's own Jabber infrastructure. Moreover, you don't have to open a port on your firewall to allow access to a given port (safe against port scanning), nor you have to have a DNS entry for the machine hosting the service: all goes through the Google Talk server.

I hope you enjoyed this little funny toy. It may have brought to you a glimpse of what services Google could provide through its open and extensible platform.

posté le 08.09.2005 à 14:23:31 par Guillaume - Catégorie : Java

Liens

Commentaires

Octavian Ghergheli a écrit :

Very interresting topic. Thanks for posting!
11.03.2008 14:22:15

rolex a écrit :

20.01.2010 16:30:25

replica watches a écrit :

24.01.2010 12:32:18

replica watches a écrit :

25.01.2010 20:12:38

replica watches a écrit :

27.01.2010 20:38:28

replica watches a écrit :

29.01.2010 23:56:22

replica watches a écrit :

The dial design a 100% copy http://www.watchvisa.com/ of the previous model: the famous Manchester Logo is http://www.watchvisa.com/ro... located at 3 and the chronograph 45-minute at 9 with orange figures. Football fans can use the very special 45-minute chronograph to measure the halves of a football match. Black hour replica watches hand and rolex watches minute hand breitling watches http://www.watchvisa.com/ca... features yellow luminescent cartier watches coating. http://www.watchvisa.com/om... The hour makers, chronograph and the first 15-minute http://www.watchvisa.com/br... scale of the chronograph counter is omega watches presented in eye-catching red. http://www.watchvisa.com/ta... Bright Yellow tones are found on the minute track, date window and the text tag heuer watches.<br/>
02.02.2010 12:57:27

weight loss a écrit :

<a href="http://www.weightlosstipspr... loss tips</a> weight loss tips
<a href="http://www.weightlosstipspr... weight fast anorexia tips</a> loss weight fast anorexia tips
<a href="http://www.weightlosstipspr... Weight Loss Tips</a> 71 Weight Loss Tips
<a href="http://www.cheap-car-auto-i... car insurance</a> cheap car insurance
<a href="http://www.cheap-car-auto-i... Pennsylvania Car Insurance</a> Cheap Pennsylvania Car Insurance
<a href="http://www.thepfmall.com">c... handbags</a> coach handbags
<a href="http://www.sanpaulou.com">e... cigarette</a> electronic cigarette
<a href="http://www.firstnfljerseys.... jerseys</a> nfl jerseys
<a href="http://blog.sina.com.cn/tom... tomic
<a href="http://nfljerseyspace.com">nfl jersey</a> nfl jersey
<a href="http://www.urbanclotheswhol... fitch wholesale</a> abercrombie fitch wholesale
<a href="http://cartier-yo.blogspot.... Montblanc</a> Cartier Montblanc
<a href="http://blackberry-fan.blogs... fans</a> blackberry fans
<a href="http://jordan-shoe.blogspot... shoes</a> jordan shoes
<a href="http://true-religion-hot.bl... religion</a> true religion
<a href="http://coach-handbags.blogs... coach handbags</a> love coach handbags
<a href="http://xiecy5566.blogspot.c... monica~yo
<a href="http://nfljerseys-yoyo.blog... jerseys</a> nfl jerseys
<a href="http://edhardy-shirt.blogsp... hardy shirt</a> ed hardy shirt
<a href="http://weight-loss-tomic.bl... loss tips</a> weight loss tips
<a href="http://ghd-tom.blogspot.com... ghd
<a href="http://seo-chan.blogspot.co... seochan
<a href="http://jerseys-chan.blogspo... jerseys
<a href="http://shoe-sky.blogspot.co... shoes
<a href="http://shoe-wholesale.blogs... wholesale
<a href="http://abercrombie-su.blogs... fitch</a> abercrombie fitch
<a href="http://tomic-zhang.blogspot... tomic
<a href="http://time-jersey.blogspot...'s up</a> time's up
<a href="http://skechers-shape-ups-s... shape ups shoes</a> skechers shape ups shoes
03.02.2010 05:14:33

weight loss tips a écrit :

03.02.2010 05:19:19

replica watches a écrit :

03.02.2010 11:08:45

tag heuer watches a écrit :

Wearing Hamilton http://www.overwatches.com/ is not the replica watches privilege for the personnel of the railway company at that time. The inspectors of http://www.overwatches.com/... railroad, even rolex watches the company workers were its potential customers. As the development of the company, the Hamilton watch company is improving itself to being perfect. Till now, it has successfully become a top watch brand which is http://www.overwatches.com/... madly loved tag heuer watches across the world.At this point, Hamilton watch company, along with the tag heuer Watches other American cartier watch makers, decided to http://www.overwatches.com/... start producing breitling wristwatches. These were further used by the train engineers and in general, by the railroad personnel. In January 1957, this watch manufacturer http://www.overwatches.com/... launched the omega watches world's first electric wristwatch. As it was a premiere, this shocked the industry quite a bit. The battery was said to offer a power http://www.overwatches.com/... reserve of one men's watches year. In these conditions, the mainspring became useless.Hamilton Watch Company represented one of the solutions. By supplying railroad companies with amazingly accurate timepieces, the http://www.overwatches.com/... Hamilton women's watch helped to save countless lives. What also helped was the adoption of a standard time plan. The four time zones, namely Eastern, Central, Mountain and Pacific were set up. The Hamilton timepieces also played an important role in http://www.overwatches.com/... railroad safety at that ladies time. As a proof of this stands the fact that the Hamilton watch was called "The Watch of Railroad Accuracy. The book published by the Hamilton Company recorded all its historical issues. Detailed description about the models and relative data of Hamilton watches are marked inside. For those who are about to buy a Hamilton watch, this book is really worthy of reading. It can certainly help you to make the right choice.
04.02.2010 09:13:26

Rolex replica a écrit :

<a href="http://www.patekphilippewat... Breitling</a>
<a href="http://www.patekphilippewat... Burberry</a>
<a href="http://www.patekphilippewat... Bvlgari</a>
<a href="http://www.patekphilippewat... Cartier</a>
<a href="http://www.patekphilippewat... chopard</a>
04.02.2010 09:59:57

tag heuer watches a écrit :

Roger Dubuis http://www.watchvisa.com/ro... is rolex watches a watch brand http://www.watchvisa.com/ta... which owns tag heuer watches many fans all over the world for the past years. That is because it is a watch brand with a reputation for creating seductive and innovative timepieces. By applying the most advanced technology, http://www.watchvisa.com/br... Roger Dubuis has breitling watches proven itself to be one of the most reliable brands in the watch making industry. This watch brand is a successful one by creating http://www.watchvisa.com/om... great timepieces omega watches.Roger Dubois has as a declared philosophy the intention to create highly individual timepieces, stating that Roger Dubuis represents a unique identity code. So far, Roger Dubuis has http://www.watchvisa.com/ca... managed to cartier watches fulfill all the requirements of a society interested in acquiring unique timepieces and its creations reflect passion for good taste, seductive design and high-end technical know how.Discover the power of curves with the new Roger Dubuis Excalibur Mens watch, with its interesting almost hexagonal case made of stainless Replica watches steel. Even though it replica approaches a sportier http://www.watchvisa.com/ appearance replica watches, the quality of the materials used is indisputable and the over all design of this timepiece is impressive. The case measures 43 mm in diameter, being quite masculine and it is covered with scratch resistant sapphire crystal. Also, surrounding the case we can see a unidirectional bezel made of white golf that's inscribed with Arabic numerals from 10 to 60, meant to help at diving.Belonging to the Easy Driver series, this watch was designed especially for the active men who are not afraid of exploring the depths of the oceans, as the new Roger Dubuis Excalibur Mens watch provides a water resistance of 1000 meters. Its automatic movement is quite impressive and it's defined by the designers from Roger Dubuis as the RD 14 Clibre.
04.02.2010 14:07:14

replica watches a écrit :

04.02.2010 20:57:55

replica watches a écrit :

06.02.2010 21:58:35

Ajouter un commentaire

:

:
:


Références externes

Cette page a été vue 27552 fois.
Dernier visiteur le 2010-02-10 04:58:06.