Powered By Blogger

Nov 20, 2014

Accessing an API without using access token

You can do this by changing the authentication level to 'None' as shown in the attached image. By default it is set to 'Application and Application User' and you can change the authentication level before Save and Publish the created API.


Invoking an API using WSO2 API manager

You can create an API to invoke the echo service in WSO2 ESB as follows

1. Start WSO2 ESB
2. Then login to WSO2 AM publisher
3. Create an API stating the production endpoint as  http://sohani-ThinkPad-T530:8280/services/echo
4. Then login to the WSO2 AM store and subscribe the API and generate the token
5. Get the prduction URL from the store to send the request
6. You can refer https://docs.wso2.com/display/AM170/Token+API about the token generation in AM
7. Now you can use the Rest client tool in AM or curl command to send the request as follows

<productionURL>/echo/echoInt?in=2




Writing a data service to execute stored procedure in WSO2 DSS

This blog post basically describes about the way to execute a stored procedure in WSO2 DSS. You can refer below steps

1. Create a sample database

CREATE DATABASE ESB_SAMPLE;

2. Create a table using below command

USE ESB_SAMPLE;
CREATE TABLE company(name VARCHAR(10), id VARCHAR(10), price DOUBLE, location VARCHAR(10));

3. Create the stored procedure as follows

CREATE PROCEDURE InsertData(compName VARCHAR(10), compId VARCHAR(10), compPrice DOUBLE, compLocation VARCHAR(10)) INSERT INTO company VALUES(compName,compId,compPrice,compLocation) ;

Now you can configure the DSS as follows

1. Download mysql connector and copy it to <DSS_HOME>/repository/components/lib

2. Create a data service as follows 

<data enableBatchRequests="true" name="SampleDataService">
  <description>Sample Data Service</description>
  <config id="Demo">
     <property name="driverClassName">com.mysql.jdbc.Driver</property>
     <property name="url">jdbc:mysql://localhost:3306/ESB_SAMPLE</property>
     <property name="username">root</property>
     <property name="password">root</property>
  </config>
  <query id="insertData" useConfig="Demo">
     <sql>Call ESB_SAMPLE.InsertData(?,?,?,?)</sql>
     <properties>
        <property name="org.wso2.ws.dataservice.query_timeout">100</property>
        <property name="org.wso2.ws.dataservice.force_jdbc_batch_requests">true</property>
     </properties>
     <param name="name" ordinal="1" sqlType="STRING"/>
     <param name="id" ordinal="2" sqlType="STRING"/>
     <param name="price" ordinal="3" sqlType="DOUBLE"/>
     <param name="location" ordinal="4" sqlType="STRING"/>
  </query>   
  <operation name="insertData" returnRequestStatus="false">
     <call-query href="insertData">
   <with-param name="name" query-param="name"/>
        <with-param name="id" query-param="id"/>
        <with-param name="price" query-param="price"/>
        <with-param name="location" query-param="location"/>        
     </call-query>
  </operation>  
</data>

3. Include the data service in <DSS_HOME>/repository/deployment/dataservices.
4. Use TryIt tool to access the data service




Setting up message tracing for WSO2 ESB


Message Tracing is basically used to trace, track and visualize a message's body of its transmission. We can use the Activity Dashboard of WSO2 BAM to trace messages going through WSO2 ESB.

First of all you need to install the message tracer feature to WSO2 ESB by following the below steps


1. Login to WSO2 ESB and select Features

2. In the Repository Management tab click Add Repository
3. Insert a name and the URL (http://dist.wso2.org/p2/carbon/releases/turing/)
4.Go to the Available Features tab and select the added repository. Under Filter by feature name field, enter BAM Message Tracer Handler Aggregate, select Show only the latest versions checkbox and click Find Features.5. The BAM Message Tracer Handler Aggregate feature appears. Select it and click Install.6. Click Finish to complete the installation.


Now in order to configure message tracing follow below steps


1. Go to the Configure menu of ESB Management Console, click Message Tracing and then click Message Tracing Configuration.2. Select all the check boxes and enter Receiver URL ((in  tcp://[IP address of localhost]:[thrift port] format), Username and Password that is used by BAM. 3. Click update.


Please note if you change the offset, change the receiver port accordingly. if the offset is 0 port is 7611, if offset is 1 it should be 7612.


Then you can publish data to BAM


1. Invoke the service

2. Login to WSO2 BAM
3.  Go to Tools menu, click Cassandra Explorer and then click Explore ClusterEnter the default values as localhost:9160, admin and admin respectively for Connection URL, Username and Password and click Connect.  

If the port offset is 1 then this should be localhost:9161


4. 
In Keyspaces, check for the published contents in the BAM_MESSAGE_TRACE column family, which is located in the EVENT_KS keyspace.