Sunday, March 23, 2014

Integrating Sharepoint with WSO2 Governance Registry

WSO2 Governance Registry (GREG) is a fully open source registry-repository for storing and managing service artifacts and other resources.

Microsoft Sharepoint is a web application platform, comprising of multipurpose set of web technologies. Sharepoint has historically been engaged with content and document management. But the latest versions can be used for lot more; document and file management, social networking, websites, intranet, extranet, enterprise search, business intelligence, system integration, process integration and workflow automation. The latest version of Sharepoint is Sharepoint 2013.

In this guide I shall show you how can we integrate Sharepoint resources with WSO2 Governance Registry. This can be useful to govern resources and artifacts stored in Sharepoint in GREG.

In this guide I will create a Sharepoint site and a blog in the site and create a resource in GREG with the blog posts URL.

You can find Sharepoint 2013 installation instructions here.

Let's first create a site in the Sharepoint 2013. You can create a sharepoint site collection using the Sharepoint 2013 Central Administration, which you can find in the start menu. This will prompt you for your Administrative user name and password, which you would have configured at the installation time. Sharepoint 2013 Central Administration window will open up in the browser as shown below.

Sharepoint 2013 Central Administration

You can create a site collection by clicking 'Create site collection' link and following the onscreen instructions. I've created a site collection called 'MySiteCollection' for demonstration and I can access the site collection by navigating to the http://win-nh67lj7lsq4/sites/mysitesYou can configure your site collections URL while following the above mentioned instructions. When you navigate to your site collection with the configured URL, you would see a similar window as the following.

Site Collection
You can create a new post by clicking 'Create a post' link and following the onscreen instructions. I've created a blog post called 'My first blog post'. After creating you can see the blog post listed in the site collection as shown in the following screenshot.

A blog post in Sharepoint

You can view the blog post by clicking the blog link. Its URL in my case is http://win-nh67lj7lsq4/sites/mysites/Lists/Posts/Post.aspx?ID=3

OK. Now we can import this blog post as a resource in the WSO2 Governance Registry. This would allow us to govern certain aspects of this resource in the WSO2 Governance Registry.

If you haven't downloaded and ran WSO2 Governance Registry, look here for the details. Navigate to the Management console in browser using the URL http://localhost:9443/carbon if you are running the WSO2 Governance Registry in the local machine and running with the default port settings.

Now let's add a resource in the WSO2 Governance Registry, corresponding to the blog post we created in the Sharepoint.  Login to the Management Console and click browse and navigate to a path where you want to store the blog post in WSO2 Governance Registry, Let's say in /_system/governace.

Click the 'Add Resource' and select 'import content from URL' for method, as shown in the following picture. Provide the Sharepoint blog post URL and give it a name. This should import the blog post content into WSO2 Governance Registry.

In case you get an error, that is most probably due to Sharepoint resources are protected. You can't access the Sharepoint resources without the authentication provided. Even if you want to access the WSDL in the browser by providing the link, you will be prompted for credentials. So how do we cope this scenario in the WSO2 Governance Registry? WSO2 products offer an option in the configuration to allow this kind of authentication to external resources happen in the network. Open up the carbon.xml located in GREG_HOME/repository/conf. There you will find a tag named <NetworkAuthenticatorConfig>. Provide the following configuration (of course changing the pattern according to your requirement and provide your credentials).

Provide your Sharepoint username and password for the <Username> and <Password> tags. <Pattern> tag allows any URL pattern matching to that to be authenticated in the WSO2 products. Type can be either 'server' or 'proxy' depending on your type.

After doing this change, you need to restart the WSO2 Governance Registry and attempt the above import. Now it should work.

By clicking the resource link the tree view would take you the following screen where you can do all the conventional governance operations for a resource. You can add lifecycles, tags, comments all in the WSO2 Governance Registry.

If you just want to save the blog post as a URI, you may do so by adding a the Sharepoint Blog URL as a URI artifact. This step will further be described below with adding a WSDL.

I'll wrap up this post by adding a WSDL file of a web service stored in the Sharepoint. The WSDL is of a default web service to list the content of a site collection. The WSDL URL of this service name List is http://win-nh67lj7lsq4/sites/mysites/_vti_bin/Lists.asmx?wsdl. Replace win-nh67lj7lsq4/sites/mysites/ with your configured site URL.

Adding a WSDL in WSO2 Governance Registry would import any dependent schema, create a service artifact type and endpoints (if available). Let's create a WSDL artifact in WSO2 Governance Registry.

Click the Add WSDL in the left pane as shown below.

Provide the WSDL URL and a name for it. This would import the WSDL and create any corresponding artifacts. In this case it creates a List service and an endpoint. You can find the service by clicking the Services in the left pane.  The endpoint dependency can be seen by clicking the 'View Dependency' in the WSDL list as shown below.

Above description indicated the way it imported the WSDL and its dependencies. You might just want to have the WSDL URL stored in WSO2 Governance Registry and not the imported content. This could be done by adding the WSDL as a URI. For that, click the Add URI button in the left pane. This should bring up a window as shown below.

Provide the WSDL URL for URI. Select WSDL for the Type. Provide the name List.wsdl (provide .wsdl extension anyway) and click save. Now go to the List URI. You should be able to see the WSDL listed there as shown below.

Click the List.wsdl. This will bring up the following windows with the dependency and associations listed in the right side.

This guide gave you a very basic guide on how to integrate some of the resources in Sharepoint with WSO2 Governance Registry. You can do lot more with WSO2 Governance Registry. I recommend you download it and play with the product and get more details from WSO2 official documentation from

Hope this guide was useful.


Thursday, March 20, 2014

Downloading and running WSO2 API Manager

WSO2 API Manager is fully open source product which allows you to create, publish and manage many aspects of APIs such as life cycle management, versioning, monetization, governance, security etc. A business has high potential for growth in using WSO2 API Manager as it allows managing APIs in a SOA environment in a decentralized manner.

Let's start getting an insight about API Manager by downloading and running it in our local machine

Download the latest WSO2 API Manager from

Extract the WSO2 API Manager into a directory. I'll refer to this directory as APIM_HOME. Navigate in to bin directory and run the WSO2 API Manager as follows.
$ ./                       in Linux
$ ./wso2server.bat                 in Windows
You would see some content in the console and finally the Managemwnt console url, API publisher URL and the API store URL.

Open up your favorite browser and open the Management console URL. 9443 is the default port, unless you have changed the offset.


Note : If you are running more than one WSO2 product at a time, make sure you increment the <Offset> in PRODUCT_HOME/repository/conf/carbon.xml to avoid conflicting ports.

You may be prompted for a security exception in the browser. Add the security exception. You would then be re-directed, after login with default user name (admin) and password (admin) to the API Management console as shown in the following. This is the administrative console use to manage aspects of the API.

API Manager Management Console

WSO2 API Manager also provides two more views, namely, API Publisher and API Store. API Publisher is the place where an API developer would create an API. He/She can also manage the life-cycle of the API in the publisher. API Store is the place where a typical API user would see, available APIs from publisher. He/She can subscribe to APIs and start using it for their own applications. Following two images are the windows of the API publisher and API store respectively in the API Manager 1.6.0.

WSO2 API Manager Publisher
WSO2 API Manager Store

This is just a startup guide for WSO2 API Manager. I recommend you to play with this product and also to refer to the online documentation for further details.


Tuesday, March 11, 2014

Accessing an existing H2 DB

H2 is one of the fastest file based database available. You can download the database from

This post is a very short guide on how to access an already existing H2 database through the command line and the browser.

Let me assume, you have a database named test.db in your home (referring it as $HOME). So the full path of your database is $HOME/test.db

First let me explain how to access the DB in command shell.

Extract the downloaded h2 zip file from the above mentioned URL. Extract it to a location of your liking. Navigate to the bin directory of the extracted directory and enter the following.
$ java -cp h2*.jar

Welcome to H2 Shell 1.3.174 (2013-10-19)
Exit with Ctrl+C
[Enter]   jdbc:h2:~/test
URL       jdbc:h2:$HOME/test
[Enter]   org.h2.Driver
Driver    org.h2.Driver
[Enter]   username
User      username
[Enter]   password
Password  password

Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit


Replace $HOME with your home directory name. Note at the end you do not specify .db extention as in test.db in the URL. Instead it is just 'test'.
Now you can enter sql commands against your DB schema.

Now let's see how to access the DB in the Web browser.

Type the following on top the bin directory.
$ java -jar h2*.jar

A web browser window should be opened as shown below.

Enter the following,

Saved Settings        : Generic H2 (Embedded)
Setting name           : Any name you like  (You can save or remove this configuration with the save and remove button)

Driver Class             : org.h2.Driver

JDBC URL              : jdbc:h2:/$HOME/test

Enter also your user name and password for the DB.

You should be able to see a window like the below. Now you can enter sql commands against your DB schema.

Enjoy using H2 DB in your applications.