Skip to end of metadata
Go to start of metadata


The RXT service client sample demonstrates the following:

  • Creating an RXT configuration model and deploying it to the WSO2 Governance Registry.
  • Generating a service stub for the deployed RXT artifact using WSO2 'wsdl2java' tool.
  • Creating, executing and testing the client.


Executing and Testing the Sample

Step 1: Create and Deploy RXT Configuration Model

The sample RXT chosen for this scenario is employee.rxt.

<artifactType type="application/vnd.wso2-employee+xml" shortName="employee" singularLabel="Employee" pluralLabel="Employees" hasNamespace="false" iconSet="11">
       <column name="Name">
          <data type="path" value="overview_name" href="@{storagePath}"/>
       <column name="Address">
          <data type="text" value="overview_address"/>
       <column name="Sex">
          <data type="text" value="overview_sex"/>
     <table name="Overview">
       <field type="text" required="true" readonly="true">
       <field type="text" required="true" readonly="true">
       <field type="options" readonly="true">
          <name label="Sex">Sex</name>

The employee.rxt shown above has been used to create the Employee[singular label of the configuration model]configurabele extension on the Governance Registry. Refer to Deploying an Extension File to deploy an extension file to the governance registry.

Step 2: Generate Service Stub

This step consists of three activities to generate the EmployeeStub using the 'wsdl2java' tool for the deployed Employee artifact.

Activity 1: View the wsdl representation for the service exposed by the Employee artifact. The wsdl uri is similar to https://{IP address}:9443/services/{singular label of the artifact}?wsdl.

Activity 2: Any wsdl2java tool can be used to generate the stub. In this sample, we use the WSO2 Application Server which has the wsdl2java facility.

  1. As the prerequisites state, download and unpack the WSO2 Application Server binary distribution from http://wso2.com/products/application-server if you haven't done already.
  2. Change the value of the <HideAdminServiceWSDLs> element in the <AS_HOME>/repository/conf/carbon.xml file to false.
  3. Navigate to <AS_HOME>/bin directory execute wso2server.sh (for Linux) or wso2server.bat (for Windows) to start the Application Server.
  4. Log-in to the AS management console and click the "tools" menu. Management console log-in is similar to that of Governance Registry. 
  5. Select wsdl2java from the tools pane which is in the left hand side of the management console.
  6. Provide the uri of the wsdl or file path of the wsdl. If the uri does not work, copy the wsdl from the browser to a text document and save it as .wsdl file and give the file path.

Activity 3: Result contains the stub java file and other skeletons with build.xml and pom.xml.

Note: Add the following dependencies to the pom.xml file if they are missing:


1. Convert that project to maven project using the mvn eclipse:eclipse command.

2. Open the project on any IDE which supports maven project.

Step 3: Create and Execute the Client

1. Add the following file to the project Employee.java.

package org.apache.ws.axis2;
import java.rmi.RemoteException;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.ws.axis2.EmployeeStub.AddEmployee;
import org.apache.ws.axis2.EmployeeStub.AddEmployeeResponse;
import org.apache.ws.axis2.EmployeeStub.DeleteEmployee;
import org.apache.ws.axis2.EmployeeStub.DeleteEmployeeResponse;
import org.apache.ws.axis2.EmployeeStub.GetEmployee;
import org.apache.ws.axis2.EmployeeStub.GetEmployeeArtifactIDs;
import org.apache.ws.axis2.EmployeeStub.GetEmployeeArtifactIDsResponse;
import org.apache.ws.axis2.EmployeeStub.GetEmployeeDependencies;
import org.apache.ws.axis2.EmployeeStub.GetEmployeeDependenciesResponse;
import org.apache.ws.axis2.EmployeeStub.GetEmployeeResponse;
import org.wso2.carbon.utils.CarbonUtils;

public class Employee {
     * @param args
     * @throws AddEmployeeServiceGovernanceException
     * @throws RemoteException
     * @throws GetEmployeeArtifactIDsServiceGovernanceException
     * @throws GetEmployeeServiceGovernanceException
     * @throws UpdateEmployeeServiceGovernanceException
     * @throws DeleteEmployeeServiceGovernanceException

    EmployeeStub stub;
    public static void main(String[] args) throws RemoteException,
        // TODO Autogenerated method stub
            String GREG_HOME ="/home/user/GREG/final_test/wso2greg-5.4.0-SNAPSHOT/";
            String axis2Repo =GREG_HOME + "repository/deployment/client";
            String axis2Conf =GREG_HOME +"repository/conf/axis2/axis2_client.xml";
            ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, axis2Conf);
            String backendServerURL = "https://localhost:9443/services/";
            String epr =backendServerURL+"Employee";
            Employee employee = new Employee(configContext,epr,false);

            /**@metadata defines the employee data to be added. The xml representation of the content should be passed which can be retrieved from the standard view of the content panel of an the employee artifact.*/
            String metadata = "<metadata xmlns=\"http://www.wso2.org/governance/metadata\">"+"<overview><sex>female</sex><name>Leonii</name>"+"<address>spain</address></overview></metadata>";
            String[] artifactIDs = employee.getEmployeeArtifactIDs();
            String id = artifactIDs[0];
            for(int i=0; i<artifactIDs.length; i++){
        } catch (AxisFault e) {
            // TODO Autogenerated catch block

    public Employee(ConfigurationContext configContext,String epr, boolean listener) throws AxisFault{
        stub = new EmployeeStub(configContext,epr,listener);
        CarbonUtils.setBasicAccessSecurityHeaders("admin", "admin", stub._getServiceClient());

    /**this method add the employee details to the running GReg instance by invoking the addEmployee() method of the EmployeeStub*/

    public String addEmployee(String addEmployeeXmlString) throws RemoteException, AddEmployeeServiceGovernanceException{
        AddEmployee addEmp = new AddEmployee();
        AddEmployeeResponse response = stub.addEmployee(addEmp);

        //prints the artifact id of the added employee artifact

        return response.get_return();

    /**Get all the artifact ids of the Employees, method returns the array of artifacts */

    public String[] getEmployeeArtifactIDs() throws RemoteException, GetEmployeeArtifactIDsServiceGovernanceException{
        GetEmployeeArtifactIDs artifactIDs = new GetEmployeeArtifactIDs();
        GetEmployeeArtifactIDsResponse getEmployeeArtifactIDsResponse = stub.getEmployeeArtifactIDs(artifactIDs);
        String[] employeeArifactIDs = getEmployeeArtifactIDsResponse.get_return();
        return employeeArifactIDs;

    /**Method takes artifactID as an input and returns the corresponding employee instance */
    public String getEmployee(String artifactID) throws RemoteException, GetEmployeeServiceGovernanceException{
        GetEmployee getEmployee = new GetEmployee();
        GetEmployeeResponse getEmployeeResponse = stub.getEmployee(getEmployee);
        return getEmployeeResponse.get_return();

    /**Method takes artifactID of the employee instance to be deleted and returns the boolean value */
    public boolean deleteEmployee(String artifactID) throws RemoteException, DeleteEmployeeServiceGovernanceException{
        DeleteEmployee deleteEmployee = new DeleteEmployee();
        DeleteEmployeeResponse deleteEmployeeResponse = stub.deleteEmployee(deleteEmployee);
        boolean deleted = deleteEmployeeResponse.get_return();
            System.out.println(artifactID+":The specified artifact has been deleted");
        return deleted;

    /**Get all the dependencies for a given artifactID, method returns the array of dependencies */

    public String[] getEmployeeDependencies(String artifactID) throws RemoteException, GetEmployeeDependenciesServiceGovernanceException{
        GetEmployeeDependencies employeeDependencies = new GetEmployeeDependencies();
        GetEmployeeDependenciesResponse employeeDependenciesResponse = stub.getEmployeeDependencies(employeeDependencies);
        return employeeDependenciesResponse.get_return();

2. Start the Governance Registry instance and open its Management Console. Then run the Employee.java as a java application from you IDE.

3. User can see the printed messages from the IDE's Console panel along with the log at the terminal.

Step 4: Functional Testing with SOAP UI

1. Download the SOAP UI tool bundle, unzip it and run the soapui.sh using the "sh soapui.sh" command inside the /bin directory.

2. Create a soap ui project.

3. Go to File -->Preferences --> HTTP setting --> tick the "authenticate preemptively".

4. When the first soap request is made the user has to give the authentication credentials for the relevant request [username, password]. It is not manadatory to give authentication credentials for the subsequent soap requests.

Adding an Employee

Soap request and response diagram for the add employee operation:

Get Employee ArtifactIDs

SOAP request and response diagram for the get employee artifacts operation:

Getting an Employee

SOAP request and response diagram for the get employee operation:

Delete an Employee

SOAP request and response diagram for the delete employee operation:

Get Employee Dependencies

SOAP request and response diagram for the get employee dependencies operation:

  • No labels