Share this blog!

This sample project maps XML data set to a JSON data set. (The input and output formats are specified at the end of the article)

1. In Eclipse with ESB tooling, create a new ESB Solution Project(If it is not already suggested start typing to filter or check under WSO2->Message Mediation->Project types). Make sure to uncheck Create Connector Exporter Project.

2. Once you create the project, you will see that two additional projects, the CAP and Registry are created.

3. Now we will create a new REST API. Right click on the project and select New->REST API

4. Give a name to the API and a context (eg. PeopleMapping and /peopleconvert respectively).

5. In the XML, add a DataMapper and a Response. We will configure the DataMapper to suit our requirements and check the Response using Postman, an API tester. In the properties, set the POST to true.






6. To start configuring the DataMapper, double click on it, specify a name and press OK.

7. To configure the input, right click on input-> Load input-> Select XML and point to your input XML file. Similarly, to configure the output, right click->Load output->Select JSON and point to the output json file.

8. Once loaded, the attributes will be visible, simply drag and drop to map to corresponding output set. Fields can be edited by right clicking on the field.







There are many operators which can be used to get the desired mapping.






9. To deploy the API, right click on the Composite Application->Export->Select WSO2 Platform distribution->Select Composite Application Archive

10. Once the CAR file is created, start the WSO2 ESB Server and in the management console add the application by uploading the .car file.

Once the application is uploaded, the API will be displayed in the deployed APIs. (eg. PeopleMapping)






To test it in Postman, copy the invocation URL. Copy the input file content in the body and specify as XML(application/xml).






When the message is sent, the required response will be obtained.



Input XML:-
<?xml version=”1.0" encoding=”UTF-8"?>
<CATALOG>
   <CD>
     <TITLE>Empire Burlesque</TITLE>
     <ARTIST>Bob Dylan</ARTIST>
     <COUNTRY>USA</COUNTRY>
     <COMPANY>Columbia</COMPANY>
     <PRICE>10.90</PRICE>
     <YEAR>1985</YEAR>
   </CD>
   <CD>
     <TITLE>Hide your heart</TITLE>
     <ARTIST>Bonnie Tyler</ARTIST>
     <COUNTRY>UK</COUNTRY>
     <COMPANY>CBS Records</COMPANY>
     <PRICE>9.90</PRICE>
     <YEAR>1988</YEAR>
   </CD>
</CATALOG>


Output JSON format:-
{“artist”: [{
             “name”: “sample_artist_name”,
             “location”: “artist_location”,
             “CD”:[{
                    “title”:”saple_title”,
                    “price”:”sample_title”
                  }]
           }]
}




For this, Eclipse Mars distribution is required (Mars 2 as of now).
In Eclipse, go to Help -> install new software
Click Add and paste the repository URL in the location and click OK. I used the following URL.

http://builder1.us1.wso2.org/~developerstudio/developer-studio-kernel/4.1.0/esb-tooling/releases/5.0.0/rc1/

If you’re running on Ubuntu 16.04 and if the software list is displayed as ‘pending’ for quite some time, make sure the GUI bug is fixed.
Hint: Add the following lines of code in the file named as eclipse.ini
openFile
--launcher.GTK_version
2


Once the list of software is displayed, select all and proceed with the installation.

For more information, please refer WSO2 docs.

"OpenShift is Red Hat's Platform-as-a-Service (PaaS) that allows developers to quickly develop, host, and scale applications in a cloud environment."

Here is a list of simple guidelines that will help you if you are struggling with the complex terms and tools.

Getting started

First of all you must have an account in OpenShift, which is quite simple. In order to create applications, you must first install OpenShift Client tools. OpenShift provides many useful guidelines and this particular set of articles is quite useful when installing the client tools. Just remember, if you're installing Ruby on Windows, try Ruby versions 1.9.3 or 2.0.0  because the newer versions might cause problems during rhc setup.

So if you're a Windows guy, go through this article until the very end. It provides a detailed guide about setting SSH keys when installing client tools.

Creating the application

In order to host a JSP project, you can select Tomcat 6(JBoss EWS 1.0) or Tomcat 7(JBoss EWS 2.0). Once you create it, copy the repo link and clone it to your local machine.


Adding a database

If your project is already built and you have a database in your local machine that must be linked to the hosting, you must add relevant cartridges to your application(As shown above). As they instruct, keep a note of the credentials that are assigned for you. 

If you are using MySQL, you can simply use phpMyAdmin to import a dump file that contains the structure and data of your database. 

In your project, edit the credentials to match those assigned for you. Basically what you will need are username, password, databasename and databaseURL. In the URL, which they will inform as 
Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/
make sure to replace the Host and Port with valid credentials. You can either use System.getenv method or directly hardcode credentials stated in phpMyAdmin. 

Uploading the war file

Once the project is all set, create a war file of the project. If you're a Netbeans fan, you can simply clean and build the project and Netbeans will create the war file in the dist folder.

In the repo cloned to your local machine, remove src folder and pom.xml file. Copy the newly created war file and paste in the webapps folder and rename the war file as ROOT.war which will set it as the root source.  

Finally go back and add, commit and push the changes to the repo using regular commands.

Good luck!
In order to perform PayPal testing, you must first need sandbox accounts. Sandbox accounts act as real accounts but the transactions that happen are not actually monetary - they only demonstrate the transactions. You can simply create them by browsing to Accounts in PayPal Developer Dashboard. PayPal Developer Documentation has numerous useful documentations for developers.

Make sure to create both a buyer(Personal) and a seller(Business) accounts.

Once the sandbox accounts are set up, you can use the following template to implement the "Buy Now" button.


You can alter the values of item and amount to be directed from the item details and proceed.
A tank game designed and developed by Yasara Peiris and me for Programming Challenge 2, where a central server will be managing a tank game with 5 players connected to it.

Visit our site
Visit Git project




Distance vector and link state are two major classes of intra-AS routing protocol. In simpler words, they are two ways of routing happening inside an autonomous system where an autonomous system is a collection of IP networks and routers belonging to the control of a single entity.

Let's consider the following as our AS for this post. Let's assume all the distances are 1.

Distance vector routing


Distance vector as the name suggests, keeps track the 'distance' to a destination and the vector or 'direction' of the destination. This is individually done by all routers to every other destination and a router does not know or care about the topology beyond its neighbors. It uses Bellman-Ford algorithm to calculate paths and it is also known as routing by rumor since a router contacts its neighbors to get the information.

Here's how A would keep track of other destinations.

Finally A would be having an information base similar to the following. 


It will contain the distance and direction to a destination from A's point of view.

Let's take a look at another node. This is how B would retrieve information.
And finally B will end up with a result like this.

Link state routing


Link state is a method where a node will be aware of all the other destinations in the AS. Each node will use Dijkstra's algorithm to calculate paths to other nodes and will maintain a tree representing the paths.

Here's how A will calculate paths to other nodes.
After calculating the distances and parent nodes relevant to each destination, the information will be saved in a tree structure similar to the following.
Similarly let's look at how B will do this.
This is B's result.
As you would see, maintaining the results obtained from link state mechanism requires more effort, causing it to have more overhead than distance vector routing. However link state is proven to be a robust  routing operation.



Blog post moved to: https://sachithradangalla.medium.com/selective-retransmission-vs-go-back-n-e823e9fc1887






Metasploit is an open source penetration testing tool that can be used to develop and execute exploit code against a remote target machine.

Let that sink in for a moment because that sentence is sufficient to completely describe what Metasploit is. And I’m here to dedicate an entire post on what that sentence is all about. Let’s start from the beginning.



If you are one of those who have been trying to use Git but were blocked by the complex keywords and commands – join the club! Here is a simple guide to share your project on GitHub with no hassle.


The number of programming languages used in the world is massive owing to the constantly evolving software industry. In order to survive in the ever-changing world of programming, one needs to be aware of all the technologies added to the popular list.

JavaScript is one such popular guy on the list which has been able to survive in the world of programming for quite a few years. Netscape’s LiveScript was the father of JavaScript, whose main job was to help develop apps easily. JavaScript overrode LiveScript by invading the server-side and set foot on a more concrete ground in the world of programming languages. Currently, Javascript is one of the most used programming languages in the world and is dominant in many aspects ranging from web pages to mobile web apps. But why is it so popular? Here is a list of reasons gathered by dzone.

1. Inexpensive to learn
The syntax is based on simple English and any programmer can follow up quickly and easily. In contrast to some popular languages, JavaScript does not require special compilers, a simple text editor and a web browser is all it needs.

2. Simple implementation
Development teams find it fascinating to be able to use a single language to face the front end and the back end.

3. Extended functionality
There are third party add-ons available that allow developers to write code snippets which can be implemented easily.

4. Client-side processing
The code is actually executed on the user’s processor and not on a remote web server which saves the bandwidth and additional load on the server. Furthermore, browsers have their own in-built JavaScript so the user is not required to download extra tools to experience JavaScript.

5. Quick feedback for the client
Gone are the days where the user has to fill in an entire form again because of a single typo made on the previously submitted one. JavaScript validates each field right after entering it.




Next PostNewer Posts Previous PostOlder Posts Home