Sunday, August 23, 2015

How to Write custom Handler to use Access Token as the query parameter in WSO2 API Manager !

Introduction
In this tutorial I'll show how to use Custom handler to use Access token as query Parameter. I'll use WSO2 API Manager 1.9.0 that is the latest release available.

Use Case

API publishing company need to expose their API validation token as a query parameter in url. In order to achieve this task from WSO2 API Manager , they have to do as following way.


Request Path of Handler


Prerequisite

[1] WSO2 API Manager (you can Download from here) .

[2] Java IDE you prefered.

[3] code base in here.


First get the code from  [3] and open in a ide you prefered .

build the code using mvn clean install command.

copy the jar in target directory into the repository/components/dropins and start the server.

If you already create the API you can see synapse API configuration on the deployment/server/synapse-configs/default/api folder in file system.

If you see an  API configuration, You can find [5] in that file.



[5]- handlers configurations
 this custom handler need to place before the APIAuthenticationHandler after place this handler you can see following handler configuration.
[6] - Modified handlers configuration


From this steps you can successfully engage the custom handler into the API. 
If you need to add these configuration into the every api you can edit the velocity template in the <Server-home>/repository/resources/api_templates.

If you see this file you can see handlers part in this file as [7] .

[7] - handlers configuration in velocity template
after the done the configuration as [8] , you can engage the custom handler into the every API you create.
 
[8] - modified handlers configuration with custom handler in velocity template

You can find custom Handler project from here

Friday, April 3, 2015

How to Connect JProfiler with WSO2 Products

Introduction

In this tutorial I will show how to Connect JProfiler with WSO2 Product.

UseCase
  • Memory usage
  • CPU usage
  • Thread profile

Prerequisite


  • WSO2 API Manager (you can Download from here) .
  • Jprofiler ( you can Download from here ) .
Install Jprofiler and get the jprofiler installation path. We consider that as "JProfiler_Home" .

Unzip WSO2 API Manager and add following line into wso2server.sh or wso2server.bat file in  <APIM_HOME>/bin folder according to the shown place

-agentpath:<JProfiler_HOME>/bin/linux-x64/libjprofilerti.so=port=8849 \





After successful configuration start the WSO2 API Manager server . You can find server is listening to the 8849 port 

Listening to Jprofiler Port 

Open the Jprofiler GUI and Select Start Center to create session to this server according to following steps

Select to Attached to profile JVM option and give the host of the server and port to monitor and select ok.


Then you have to select Instrumentation or Sampling as the setting . On Instrumentation its give full features from the profile and Sampling we can only monitor the CPU usage of the server.



After successfully configured into the Server we can see following view .


According to this view we can find how many instances will create according to the class name .





Sunday, March 22, 2015

How To integrate WSO2 BPS server with WSO2 API Manager


Introduction
In this tutorial I will show how to integrate WSO2 API Manager with WSO2 BPS Server

Use Case

Company A  is API publishing company and this company want to manage the subscribers come into their API Store . In order to make this use case success we use WSO2 Business Process Server to handle the requests come into the store.

Types of Requests Handle by the BPS
  • User Signup Workflow 
  • Application Creation Workflow
  • Application Registration Workflow
  • API Subscription Workflow

Prerequisite


  • WSO2 API Manager (you can Download from here) .
  • WSO2 Business Process Server ( you can Download it from here) .

Deployment Diagram


Deployment Diagram




  • Unzip the WSO2 API Manager and start the server .
  • Unzip the WSO2 BPS and change the portoffset to 2 from the carbon.xml in the <BPS_Home>/repository/conf.
  • Copy <AM_HOME>/business-process/epr folder into the <BPS_HOME>/repository/conf folder and start the server.
  • Log into the BPS management Console from https://<hostname>:9445/carbon .
  • Deploy Human Task Zip file and the Business Process zip file from the <AM_Home>/business-process/user-signup .
  • Log into the management console in WSO2 API Manager from https://<hostname>:9443/carbon.
  • find workflow-extension.xml from registry on /_system/governance/apimgt/applicationdata/workflow-extensions.xml and change the configurations according to following workflow-extensions.xml
workflow-extenstions.xml

After successfully configured the server you can check the functionality as follows.

  • Go to API Store from https://<hostname>:9443/store
  • Go to signup and Create subscriber.
  • After Do Signup you'll acknowledge with following message from Store
Signup Notification From Store
After this step admin can approve your account from login to the admin-dashboard in API Manager.









Saturday, March 21, 2015

How To Create Axis2 Client for Axis2 Service using Maven


This Article is continuation of previous article on How to Create Axis2 Web service Using Maven Project .

Creating Project Structure

create new maven project name OrderProcessClient.

groupId : org.wso2.carbon
artifactId : OrderProcessClient
version : 1.0.0

Include following configuration to the pom.xml


pom.xml

Start the axis2 server that start in previous tutorial.
Download wsdl file of the service in to project Resource folder by going to the OrderProcessService link and build the project.
From this Step Service Stub class of the Service is generated in the org.wso2.service package.

Writing Client Code by Use of Service Stub Class

Create OrderProcessClient class in org.wso2.client folder
OrderProcessingClient.java
Finally you can run this class and check the functionality of your service.





Wednesday, March 18, 2015

How to Create Axis2 Web service Using Maven Project

Introduction

The Apache Axis2 is a Java-based implementation of both the client and server side of the web service. Apache Axis2 provides a complete object model and a modular architecture that makes it eas to add functionality and support for new web service related specifications and recommendations.

Prerequisite


1. Axis2 Server ( you can download from here ) .

2. Intelij Idea  ( you can download it from here ) .

3. Maven (you can download it from here ).

Creating the project Structure


create new maven project name OrderProcessWS.

groupId : org.wso2.carbon
artifactId : OrderProcess
version : 1.0.0

Include following configuration to the pom.xml

Package Creation


Create org.wso2.data and org.wso2.service packages
org.wso2.data -this package contains DAO classes need for web Service.
org.wso2.service - this package contains the operations related to the service

Writing Classes


Create Item and OrderDetail classes in org.wso2.data package

Item.java


OrderDetail.java

create ProcessOrders class in org.wso2.service package
ProcessOrders.java

Writing Services.xml

services.xml contains the details of the service that we exposed . This configuration file have to create inside the src/main/resources/META-INF folder

services.xml

name :  The service name will be the name of the archive file if the .aar file contains only one service, or else the name of the service will be the name given by the name attribute.

scope :  (Optional Attribute) The time period during which runtime information of the deployed services will be available. Scope is of several types- "application", "soapsession", "transportsession", "request". The default value (if you don't enter any value) will be "request"

class :  (Optional attribute) The full qualified name of the service lifecycle implementation class. ServiceLifeCycle class is useful when you want to do some tasks when the system starts and when it shuts down.

Description :  (Optional) If you want to display any description about the service via Axis2 web-admin module, then the description can be specified here.
For more information go here.

Finally build the maven project and copy  OrderProcessService.aar file inside the project target into <Axis2_HOME>/repository/services and start the axis2 server.
you can find the wsdl represenation of the soap service by browse
http://localhost:8080 and select the OrderProcessService from
deployed services list.