This documentation is for WSO2 Application Server version 5.0.0. View documentation for the latest release.

JavaScript Stub Generator

The easiest way to access a Web Service hosted externally is through a stub. The "JavaScript Stub Generator" is a productivity tool enabling client code generation according to a given WSDL. Its functionality is provided by the following feature in the WSO2 feature repository.

Name: WSO2 Carbon - Javascript Stub Generator Feature
Identifier: org.wso2.carbon.jsstubgenerator.feature.group

The stub generation functionality is bundled by default in the WSO2 Application Server and WSO2 Mashup Server products. If it is not included in your product distribution, you can add it by installing the above feature using the instructions given in section Feature Management. 

Follow the instructions below to invoke the tool.

1. Log on to the product's Management Console and select "JavaScript Stub Generator" in the "Tools" menu.

2. The "JavaScript Stub Generator" window appears.


The required WSDL can be uploaded as a file or can be given as a URL, where the stubs can be generated according to the E4X specification or according to DOM.

  • E4X Stub: The E4X stub is to be used to access a service from a service.
  • DOM Stub: The DOM stub is to be used in browser environments.

3. Once a WSDL file or WSDL file URL is given, click the "Generate from File" or "Generate from URL" button associated with the relevant upload option. You can see the generated stub in the text area. For example,

Shown below is how this script is imported to a Mashup.

Create a new Mashup, say 'Currency' and save it. You will find a Currency.resources directory created in your personal scripts directory: <PRODUCT_HOME>\repository\deployment\server\jsservices\admin. Create a new text file in the Currency.resources directory for the stub and paste the generated stub in it. Let's assume it 'convertor.stub.js'.

Edit the mashup and include an import statement to bring in your stub as follows: