What is an ESB
An enterprise service bus (ESB) is a software architecture model used for designing and implementing communication between mutually interacting software applications in a service-oriented architecture (SOA). As a software architectural model for distributed computing it is a specialty variant of the more general client server model and promotes agility and flexibility with regard to communication between applications. Its primary use is in enterprise application integration (EAI) of heterogeneous and complex landscapes. - Wikipedia
WSO2 ESB is the best 100% open source ESB available in the current market. It can be considered as the highest performance, lowest footprint, and most interoperable SOA and integration middleware today. - WSO2 ESB
Prerequisites
- JDK should be installed in your computer
- HelloAxis.aar (Creating HelloAxis.aar) or some other web service archive file.
- Maven (To generate the client source)
Getting Started
You can download the latest WSO2 ESB binary distribution from the WSO2 website (WSO2 ESB Download Page). WSO2 ESB 4.8.1 is the latest stable release. Download that and extract it into any place that you like. When will you extract, it will be looks as follows.
You can download the latest WSO2 ESB binary distribution from the WSO2 website (WSO2 ESB Download Page). WSO2 ESB 4.8.1 is the latest stable release. Download that and extract it into any place that you like. When will you extract, it will be looks as follows.
Before creating the proxy we need to deploy our web service. Here I'm using a separate axis2 server. Refer HelloAxis2 post to see how to deploy the file in Axis2 server. You can use axis2 server bundle with WSO2 ESB to deploy the service. You are also free to deploy it anywhere that you like.
Deploy using axis2 server in WSO2 ESB
Copy the HelloAxis.aar file to wso2esb-4.8.1/samples/axis2Server/repository/services
You can start the Axis2 server using the axis2server(.bat or .sh) script in the wso2esb-4.8.1/samples/axis2Server folder. By default this axis2 server will starts on port 9000. If the server get started successfully and the web service is deployed without any iussues, you can see the HelloAxis service is available on the Web service list in localhost:9000/services/
Starting ESB
You can start the WSO2 ESB using the wso2server script in the wso2esb-4.8.1/bin directory
Ubuntu
wso2server.sh
Windows
wso2server.bat
Note
WSO2 ESB get starts in INFO mode by default. If you like to start the ESB in debug mode, you have to do a small change. To do so
Open the log4j.properties file in the wso2esb-4.8.1/repository/conf folder. In the file you can find a entry looks
log4j.category.org.apache.synapse=INFO
changed that to
log4j.category.org.apache.synapse=DEBUG
When you run the wso2server script you will see some log entries getting print on terminal and if the ESB get started successfully you will see something similar to
You can open the browser and go to the URL mentioned(https://localhost:9443/carbon) there the WSO2 ESB management console. Probably you will see some security warning when you go to the URL. Just ignore it this time.
You can use admin as both username and password to login to the ESB console.
Go to the Proxy services section under the Services and select Pass Through Proxy from the templates.
In the next screen you must specify information relate to your service.
- Proxy service name - This will be use as the name of our proxy. You can give any name that you like
- Target URL - Specify the deployed web service URL. This is what you are accessing through the proxy e.g. HelloAxis service
- Select Specify source URL in the publishing WSDL section in the Publish WSDL Options and provide URL to WSDL of the deployed service
- Press Create button.
You will see a message box saying proxy is created successfully and you should see the newly created Proxy service in the Deployed service list.
Creating a Client
Click on the proxy service name that you created from the list. Then click the Generate Axis2 Client in the Client Operation section in the right hand side of the screen.
In the next screen you will see set of options relate to generating client code. I will just provide a custom package name, while keeping other settings as it is. Click generate button.
This will create a .zip file which consists of a pom.xml file. We can use this pom.xml file to generate the client source code.
You can use your favorite IDE or plain maven commands to generate the source code.
Before generating the source, first open the pom.xml from your favorite text editor and changed
<properties>
<axis2_version>1.6.1-wso2v10</axis2_version>
</properties>
to
<properties>
<axis2_version>1.6.1-wso2v9</axis2_version>
</properties>
To generate the source code without any IDE support
mvn generate-sources
To generate source and create eclipse project
mvn eclipse:eclipse
If you are using IdeaJ IDE you can import this pom.xml file and generate the source code.
After generating the source, create a simple Java class as follows.
import org.apache.axis2.AxisFault;
import java.rmi.RemoteException;
public class ESBClient {
public static void main(String[] args) {
try {
SimpleProxyServiceStub stub = new SimpleProxyServiceStub("http://localhost:8280/services/SimpleProxyService");
SimpleProxyServiceStub.SayHello sayHello = new SimpleProxyServiceStub.SayHello();
sayHello.setName("Thusitha");;
System.out.println(stub.sayHello(sayHello).get_return());
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
When you run this you will get the output Hello Thusitha
This output implies that our HelloAxis2 web service get called through the proxy service that we create using WSO2 ESB.
Hello..
ReplyDeleteis wso2 esb create file when start?