Translate

viernes, 28 de noviembre de 2014

Webservice Example with axis2 part 2: Understanding a webservice

This is the second post to show how to create a web service with a simple operation and a complex operation based on Axis2.

In this series of posts we are going to show this points:









Now we are going to learn how a webservice works and the main concepts.

The main part of a webservice is the WSDL file that describes the webservice interface. This interface describes the available operations in the webservice and the input and output parameters of all operations. This file will be the defined using a template java class and the java2wsld java tool that transform a java class in a WSDL file.

Another important concept of the webservice is the endpoint, the endpoint is an URL that you have to know in order to use the webservice. This endpoint is where the server are listening for your requests and where the server code are executed when a webservice operation is called. Finally an output is returned to the client in order to response to the request, this is the server part of the webservice.

The WSDL file is always public and you can access it via URL to see the available operations and mainly to build a client using the wsdl2code java tool that can create a collection of java classes based on a WSDL file in order to use the webservice. With this client you can invoke the available operation of the webservice, this is the client part of the webservice.

This comunication bettwen the client and the server part of the webservice is made by the soap protocol (Simple Object Access Protocol). 




Example:

We have the webservice named Axis2ServiceExample  with the next operation:

Name: simpleOperation
Input Parameters: number1: Integer, number2: Integer
Output Parameters: Integer - Return the add of the input numbers.

WSDL File: http://localhost:9763/services/Axis2ServiceExample?wsdl
endpoint:  http://localhost:9763/services/Axis2ServiceExample/

All of this things are defined in the WSDL file, in the next sections we will see how to the create all parts of the webservice and call to the operation.

References:





domingo, 9 de noviembre de 2014

Webservice Example with axis2 part1: Setting environtment

This is the first post to show how to create a web service with a simple operation and a complex operation based on Axis2.

In this series of posts we are going to show this points:

The first thing to do is set up the necesary environtment to create the web service. Download the next sofware and configure the environment variables:

•    Java SDK version 1.6.0_45 or later.
•    Windows environment variable JAVA_HOME pointing to Java location (C:\Program Files\Java\jdk1.6.0_45)
•    Eclipse IDE version 4.3 Kepler or later.
•    Apache Maven version 3.1.1 (Embedded in IDE or installed in local machine to use it in command line console).
•    Add the apache Maven bin directory path to the Windows environment variable Path
•    Apache Ant version 1.9.4, installed in your local machine.
•    Add the apache Ant bin directory path to the Windows environment variable Path
•    Apache axis2 version 1.6.0  (binary distribution). Libraries XMLBeans version 2.3.0 and axiom version 1.2.11 are included in axis2.
•    Windows environment variable AXIS2_HOME pointing to Axis2 location (C:\axis2-1.6.0)
•    WSO2 application server version 4.0.1 to deploy Web services.  (you have to download the version 5.0.0 in the download page)

The next step is check if all the elements are properly installed.

JAVA
Open a dos command window and execute java -version





ECLIPSE
Execute the eclipse.exe in your eclipse installation



APACHE MAVEN

Open a dos command window and execute mvn -version





ANT
Open a dos command window and execute ant -version



AXIS2
Open a dos command and execute echo %AXIS2_HOME% and check that path y correct.



WSO2 - Application Server
Open a dos windows and run the server using this command.
[WSO2-Installation-folder]/bin/wso2server.bat



Open browser and copy the url that appears in the last line of the output

Enter user admin and password admin





If you are here everything has going ok.