JavascriptService Sample Guide for WSO2 Web Services Application Server , v2.1-RC4

INTRODUCTION

We will use this sample to demonstrate the capabilities of WSO2 WSAS in terms of the flexibility in deploying services. A service could be written entirely in Javascript using the easy to use E4X (ECMAScript for XML) syntax and deployed on WSO2 WSAS.

SCENARIO

For the sake of simplicity we will illustrate an echo service written in javascript. The javascript source is kept in the WSO2WSAS_HOME/samples/JavascriptService/js and it has the following simple piece of code.

function echo(echoXML){
    return echoXML;
}

Advanced services could also be implemented using Javascript functions as in the above example. The only requirement is that the return value from the javascript function should be an XML. The argument to the function is an XML and E4X syntax can be used to easily manipulate the XML to implement the business logic.

HOW TO BUILD AND RUN THE SAMPLE

JavascriptService sample is in WSO2WSAS_HOME|samples|JavascriptService.

To build the samples you need Apache Ant build tool.

Now follow these simple instructions:

  1. Run WSO2 WSAS. See Installation Guide for installation details.
  2. Switch to the JavascriptService directory, e.g.
  3.    cd WSO2WSAS_HOME\samples\JavascriptService
  4. From there simply type
  5.    ant
    The build automatically copies the JavascriptService.aar file containing the service into the repository. If you select the Services page in the Management Console, you should see the JavascriptService deployed. (See Administrator?s Guide on how to sign into Management Console and to navigate through it.)

Method 1:

Method 2:

APPENDIX