WSO2 Governance Registry - WS API [ Documentation Index ]

Web Services API of the WSO2 Governance Registry

The operations of the WSO2 Governance Registry can now be accessed through Web Service calls using the Web Service API (WS-API). The WS-API supports almost all operations exposed through the main Registry API. A WS client is provided for the WS-API which allows you to access the Registry just as you would through the main Registry API.

Setting up the WS API Registry Client

The following code shows how to set up the WS Client and authenticate it against an instance of the Governance Registry. NOTE: It is assumed that default configurations of the Registry have not been changed.

First, we have to set the system properties to enable the https connection.

String GREG_HOME = /path/to/Governance_Registry
System.setProperty("javax.net.ssl.trustStore", "GREG_HOME/resources/security/client-truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
System.setProperty("javax.net.ssl.trustStoreType","JKS");


A number of parameters are required to initialize the client. These are initialized in the following code:

String axis2Repo = GREG_HOME + "/repository/deployment/client";
String axis2Conf = GREG_HOME + "/repository/repository/conf/axis2_client.xml";
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, axis2Conf);


The final steps of the initialization is done in the following code segment:

String username = "admin";
String password = "admin";
String backEndServerURL = "http://localhost:9763/services/";
String serverURL = "https://localhost:9443/services/";

WSRegistryServiceClient registry = new WSRegistryServiceClient(serverURL, username, password, backEndServerURL, configContext);

Please run an "ant" command at GREG_HOME/bin and add all the jars created in GREG_HOME/repository/lib to the class path prior to running the examples in this guide.

Now, if you now run this example, an output similar to the following output will be generated at the server side console
Console output for Admin login through WS-API



This client instance can now be used just as using the Registry API. Some of the possible operations are illustrated below:

Adding a resource to the registry

Resource r1 = registry.newResource();
String path = "/dev_guide/r1";
String r1content =  "R1 content";
r1.setContent(r1content);
registry.put(path, r1);

View of added resource displayed in web browser

Commenting, tagging and rating a resource

registry.addComment(path, new Comment("This is a WS-API comment"));
registry.rateResource(path, 5);
registry.applyTag(path, "WS tag");

Added comment, rating and tag displayed in web browser

Moving and renaming a resource

String newPath = "/dev_guide_new/r1_move";
registry.move(path, newPath);
registry.rename(newPath, "r2_renamed");

View of moved resource displayed in web browser

Retrieving the resource's content

Resource resource = registry.get("/dev_guide_new/r2_renamed");
System.out.println(new String((byte[])resource.getContent()));

This will output the original content to the console, i.e. "R1 content"

Most of the operations of the Registry API is supported by the WS API. Please refer the Registry API for more information

Setting up WS-Security for the WS-API

To add WS-Security for the WS-API, just name the relevant policy file as "ws-api-sec-policy.xml" and place it into GREG_HOME/repository/conf. WS-Security will now be engaged!