Sunday, June 30, 2013

WSO2 Governance Registry Checkin client - Dump Registry Resources To A File System

In WSO2 Governance Registry you can dump the registry content into a file system or a single file where you can use it to restore the registry to that SNAPSHOT. In addition to that when you dump into a file system you can do changes to it and commit. Here I am talking about how you can do it.


Dump the registry resources into a file system.
Command -
Linux : sh checkin-client.sh co https://localhost:9443/registry/ -u admin -p admin
Windows : checkin-client.bat co https://localhost:9443/registry/ -u admin -p admin

In the following content I will be describing the additional functionalities we introduced after Governance Registry version 4.5.3.

1. Add - Use of this is to add new resource in the client side. This will be reflected in the registry when committing. In earlier versions of checkin client there were no option like this and whatever we put in the checked in location will be committed. But now the resource must be add to reflect in the registry.
Command -
Linux - sh checkin-client.sh add x.xml
Windows checkin-client.bat add x.xml

If you want to specify the mediatype when adding you can follow the following commands,
Linux - sh checkin-client.sh add x.xml -mediatype application/policy+xml
Windows checkin-client.bat add x.xml -mediatype application/policy+xml

[NOTE] Though we are specifying the mediatype it won't go through the registry handlers when we committing to the registry.

2. Delete - Use of this is to delete a resource which is checked in using checkin client.  This will be reflected in the registry when committing and will not delete the local resource until then (this method is for the purpose of reverting). In earlier resource can be deleted using OS delete but in the current version it won't delete the resource in the registry untill the resource deleted using the delete command.

Command -
Linux - sh checkin-client.sh delete x.xml
Windows checkin-client.bat delete x.xml

3. Add/Update property - Using this method you can add, update a resource property. You can set any number of properties in one command as key value pairs.
Command -
Linux - sh checkin-client.sh propset x.xml property1 value1 property2 value2
Windows checkin-client.bat propset x.xml property1 value1 property2 value2

4. Delete Property - Using this command you can delete a resource property. You can delete any number of properties in one command giving key set.
Command -
Linux - sh checkin-client.sh propdelete x.xml property1 property2
Windows checkin-client.bat propdelete x.xml property1 property2

Check in the changes
Command-
Linux - sh checkin-client.sh ci -u admin -p admin
Windows - checkin-client.bat ci -u admin -p admin

[NOTE] In the current model when checkin to the registry all the resource won't restored to the registry unless there are changes in the local resources. Change in the content or property, resource add and resource delete will be consider as change of property and will only checkin those changed resources to the registry. 

There are still certain limitations which we are working on overcome them and will be fixed in next release.

Monday, June 17, 2013

Configure WSO2 API Manager to send responses to a client which does not support chunk transfer encoding

Some client applications which used the API Manager to invoke APIs may not support chunk transfer encoding and some client applications may need Content-length HTTP header for their application usage. Since by default API Manager gateway sends the response with chunk transfer encoding in either case aforementioned you need to disable the chunk transfer encoding in the response. In this post I am going to show you how to do that.
When creating an API, API Manager will automatically crate a proxy for it in the API gateway which accept the requests on behalf of the actual API. The configuration of that proxy can be found in $CARBON_HOME/repository/deployment/server/synapse-configs/default/api/${PUBLISHER}--${API_NAME}_v${API_VERSION}.xml. In my example I used a API named MovieAPI and version 1.0.0 which published by the publisher eranda and my proxy configuration file is $CARBON_HOME/repository/deployment/server/synapse-configs/default/api/eranda--MovieAPI_v1.0.0.xml
If you check the configuration you will see a configuration which similar to a ESB proxy configuration. So to make it disable the chunk transfer encoding you need to add it to the out sequence as in the following configuration.
        
            
            
            
        
Additionally if your backend API does not support chunk encoding you need to add aforementioned two additional properties to the inSequence.

Thursday, June 6, 2013

How to set port offset of WSO2 API Manager 1.4.0

WSO2 API Manager is a complete solution for managing API through its lifecycle, powered by WSO2 Enterprise Service Bus, WSO2 Identity Server, WSO2 Governance Registry and WSO2 Business Activity Monitor.
Today I am going to talk about changing the port offset of WSO2 API Manager. Basically my requirement here is to start two servers in the same server without clashing each other but everybody who need to have a port offset in WSO2 API Manager should follow this.


WSO2 API Manager is bit different than the other WSO2 servers from setting the offset since we it has little more work than other servers where in other WSO2 servers we only have to set the offset value in the carbon.xml. Following steps shows you how to set port offset in WSO2 API Manager.
  • Set offset in the $CARBON_HOME/repository/conf/carbon.xml to any value you want.
 
         
         2
  • Set the Thrift client and server ports in $CARBON_HOME/repository/conf/api-manager.xml to (10397 + portOffSet) as shown in below.
        

        ThriftClient
        10399
        10000
        10399
        
        true
  • This is the most valuable configurations where without this configuration API Store will never work with port offset. Now change the endpoint configuration in the following files to suit your port offset

    1. $CARBON_HOME/repository/deployment/server/synapse-configs/default/api/_LoginAPI_.xml - This configuration involves with user login to the API Store.
    2. $CARBON_HOME/repository/deployment/server/synapse-configs/default/api/_TokenAPI_.xml - This configuration involves with generating OAuth token.
    3. $CARBON_HOME/repository/deployment/server/synapse-configs/default/api/_AuthorizeAPI_.xml - This configuration involves with authorize a OAuth token.
         Here is a sample configuration for _AuthorizeAPI_.xml where my offset is 2.
<endpoint>
    <address uri="https://localhost:9445/oauth2/authorize"/>
</endpoint>
    Now you are done and your WSO2 API Manager is ready to start with the port offset.