Pages

Subscribe:

Ads 468x60px

Featured Posts

Monday, August 25, 2014

Using WSO2 admin services to upload Carbon Applications - With Sample

Hi all, in this post we are going to explore how to use carbon admin services and how to consume them properly. There are lot of carbon admin services available for WSO2 Carbon based product.
To list  out all the admin services follow the below steps.
Start a WSO2 product using the following command. In this particular example I am using WSO2 ESB 4.8.0
aruna@aruna:~$ ./wso2server.sh -Dosgiconsole

Then type listAdminServices in the Osgi Console.

aruna@aruna:~$ listAdminServices
Now you can see all the available admin services.

By default these admin services are hidden. If you try to access a service using browser. you'll get the following error.

<faultstring>
The endpoint reference (EPR) for the Operation not found is /services/ProvisioningAdminService and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.
</faultstring>

To enable hidden admin services in Server-Home/repository/conf/carbon.xml file set the following value to false.
<HideAdminServiceWSDLs>true</HideAdminServiceWSDLs>

Then you'll see the wsdl file of the service available.
Here is a sample admin service client to demonstrate an uploading a carbon application to the server.
You can find the source code in this repository.
Repository Link    http://bit.ly/1vf8hkS

Saturday, June 14, 2014

Mount WSO2 products to a remote WSO2 Governance Registry instance(MsSQL 2012)

In this post we are going to mount wso2 products into a remote governance registry. In the default scenario wso2 governance registry is pointed to a local h2 database.

First lets configure the governance registry instance to point to the MsSQL data source.
  • Download WSO2 Governance Registry product and extract the product.
  • Go to /repository/conf/datasources  and open master-datasources.xml
  • Then change the following entries in the WSO2CARBON data source.
<datasource>
            <name>WSO2_CARBON_DB</name>
            <description>The datasource used for registry and user manager</description>
            <jndiConfig>
                <name>jdbc/WSO2CarbonDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:sqlserver://127.0.0.1:1433;databaseName=REMOTEDB</url>
                    <username>sa</username>
                    <password>pass#word2</password>
                    <driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
</datasource>

  • Fill the url, username, password according to your MsSQL Instance.
  • Log into the MSSQL 2012 Management studio and create a database called REMOTEDB
  • Then move to the /repository/components/lib folder in the extracted greg product folder and copy the downloaded MsSQL JDBC Connector. You can download the sqljdbc driver from this link. Download
  • Then Start the WSO2 governance product with the -Dsetup option. (-Dsetup option will populate the new schemas in the newly pointed MsSQL REMOTEDB)
D:\blog\wso2greg-4.6.0\bin>wso2server.bat -Dsetup

 Now lets mount a WSO2 product to this remote registry. 

  • Let's use WSO2 API Manager for this example post. First Download the product and extract it to your hard drive.
  • Go to /repository/conf/datasources folder and open the master-datasources.xml file
  • Then add a new data source as follows. For the demonstration purpose lets name the new datasource as WSO2_CARBON_DB2.
<datasource>
            <name>WSO2_CARBON_DB2</name>
            <description>The datasource used for registry and user manager</description>
            <jndiConfig>
                <name>jdbc/WSO2CarbonDB2</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:sqlserver://127.0.0.1:1433;databaseName=REMOTEDB</url>
                    <username>sa</username>
                    <password>pass#word2</password>
                    <driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
</datasource>

  • Note that this datasource is a completely new entry and let the default config reamins as it is.
  • Now as we did in WSO2 governance product copy the saljdbc driver to the /repository/components/lib folder
  • No open up the /repository/conf registry.xml file in the WSO2 API Manager product and do the following changes.
  •  Add a new dbConfig as follows
<dbConfig name="remoteRegistry">
       <dataSource>jdbc/WSO2CarbonDB2</dataSource>
</dbConfig>
  • Note that the dataSource is set to the jndiConfig name which we used in the new datasource defined in the API Manager's master-datasources.xml
  • Now find the following configuration, uncomment it and change it to the following config values.
<remoteInstance url="https://localhost:9443/registry">
        <id>apimanager</id>
        <dbConfig>remoteRegistry</dbConfig>
        <readOnly>false</readOnly>
        <enableCache>true</enableCache>
        <registryRoot>/</registryRoot>
</remoteInstance>
  • Note that the dbConfig name is set to the newly added dbConfig name, which is "remoteRegistry" in this example. Give a unique id value.
  • Then we set the remote mounted path using the following configuration.
<mount path="/_system/config" overwrite="true">
        <instanceId>apimanager</instanceId>
        <targetPath>/_system/amnode</targetPath>
</mount>
  • This configuration is comment by default and you have to uncomment and provide the relevant values. Note that the instanceID value is same as the id value in remoteInstance configuration.
  • The target path is set to /_system/amnode if you are using several API Manager nodes you can set all to the same path. If it is a different product it is recommend to use a different path for example ESB node path would be /_system/esbnode
  • /_system/config is the path which the product is going to be mounted.
  • Now finally if you have followed the above steps correctly start the API Manager with some port Offset if the product is running in the same machine.
D:\blog\wso2am-1.6.0\bin>wso2server.bat -DportOffset=100
  • Now log into the API Manager Web UI using the following URL https://192.168.1.2:9543/carbon/
  • If you browse the resource can see the remotely mounted /_system/config registry.
API Manager Resource view
That's it for now. Feel free to shore your thoughts about the post. :)