Tuesday, July 1, 2008

Web Services Cannot Get Any Simpler

If someone was to ask "what is the easiest method to write a Web Service?" my definite answer would be the WSO2 Mashup Server. The WSO2 Mashup Server helps you write services (or Mashups which ever you want to call it) using JavaScript with the E4X extension. Will blog more about E4X and its ease of use in the coming days (Stay tuned for that). Writing Services using the Mashup Server can be done in a matter of minutes. Here is the simplest Web Service you could write,

function sayHello() {
return "Hello";

Just drop this bit of script as a file into a magic folder (Into your mashups folder found in the scripts directory. Each user is given his own mashups folder depicted by his username) with the .js extension (example hello.js) and your service will get deployed. Lets assume that hello.js was dropped into scripts/keith. This would make the service available at http://localhost:7762/services/keith/hello. Browse to the above location and see what happens. The Mashup Server will show you a tryit page. This is a page thats generated by the Mashup Server on the fly so that you can test your web service out.

You can even access the sayHello service by pointing your browser to http://localhost:7762/services/keith/hello/sayHello. This would invoke the sayHello function in a RESTfull manner.

One can also use the Mashup Server without downloading it. Check out mooshup.com which is a Mashup Server that we've hosted for you. Try creating your own mashups there (You will have to use the UI to create services there cause you do not have direct access to the file system). You can even create a mashup on your local distribution and share it to mooshup. You can have a look at this simple hello service at https://mooshup.com/mashup.jsp?path=/mashups/keith/hello. BTW the Mashup Server is released under the Apache License. So you can download and give it a try your self too. There are no restrictions.

This is the simplest Web Service one could write. The Mashup Server has capabilities to do much more for you. Please refer the Mashup Server project page for more details.

Stay tuned for more tips and tricks about the WSO2 Mashup Server and also Apache Axis2 (The engine behind the Mashup Server)

No comments: