Writing a Hello World Service
JavaScript
The Mashup Server supports the quick and easy creation of Web
services
written in JavaScript. Just as a Web server such as Apache or
IIS publishes
HTML and other Web content from a local directory to the Web, the
Mashup
Server takes JavaScript files, placed in a local directory, and exposes
the
functions as Web Service operations.
The simplest way to deploy a new Web service is simply to write some
JavaScript and place it in your home directory (A directory which
corresponds to your username. Placing it in any sub folder which is
under the scripts directory will work, but the Author of the service is
infered from where the script was placed.) which is located under the
'scripts' directory of the Mashup Server. Alternatively you
can use the Create new service wizard from the UI. Follow these simple steps (Assuming that your username is bob):
Step 1:
In Notepad or your favorite IDE, type the following text:function hello() {
return "Hello
World";
}
Step 2:
Save this file as 'helloworld.js' in your home directory (Assuming that your username is bob) which is located under the 'scripts' directory of the Mashup Server.
Step 3:
That's it, the helloworld service is now live, exposing a single operation 'hello' that returns the text "Hello World". But let's try it out to make sure it's working properly. Open up the WSO2 Mashup Server web-based console (typically at https://localhost:7443/) and look for the helloworld mashup you just created. If you are signed in it will be listed under your mashups else you can use the searching facility of the Mashup Server to look for the helloworld mashup.
Click the 'Try the service' link which is in the human resources section of the Mashup Page or try typing the tryit URL (typically at http://localhost:7762/services/bob/helloworld?tryit) in the browser, and you will get a web-based client that can interact with the Web service. In this case just click the button titled hello >> to invoke the hello operation. The response is illustrated below:
The Helloworld mashup also contains many helpful resources which are described here.
Adding an user Interface for your service
When a service is deployed, Mashup server automatically creates a folder to store the resources that belong to the service. This folder is named as "{service javascript file name}.resources". You can install a custom user interface for your service by creating a folder named "www" under the above mentioned resources folder and placing the necessary files under the created "www" folder. This user interface will appear when you point your browser to the Endpoint Reference of the service (eg: http://localhost:7762/services/bob/helloworld). Refer to the deploying Javascript services for more details on the mashup server deployment structure. The Mashup Server also creates a "_private" folder under your resources folder. Any content placed in this folder will not be transfered during sharing or downloading of mashups. Therefore this folder can be used to save data that you need to keep private during shring of mashups.

Please refer to "writing
hello world
client" for more information about creating AJAX clients for
the mashup
services deployed in the WSO2 mashup server.