Axis2-Services Clase 1
Axis2-Services Clase 1
Axis2-Services Clase 1
Agenda
Overview of Web Services Installing Apache Axis2 Making Java-First (Bottom-Up) Web S Services i Deploying and testing your services
Web Services
9
Interoperability
Definition of request q and response p data lets any y Web service interact with any other.
Industry support
V Very widely id l adopted. d d No N d danger of fi investing i in i short-lived h li d fad f d ala l Ada and CORBA.
10
WSDL
XML-based description of a Web service
Where it resides What it can do How to invoke it
UDDI
XML-based registry g y to list and find Web Services Stands for Universal Description, Discovery and Integration
11
Apache Axis2
Set of tools to simplify Web Services
Services S i
Create a Web service from any Java class Create Web service stubs from WSDL files Build B ild WAR file fil for f deployment d l t on any Java-based J b d server
Clients
Create client stubs from WSDL files
Usage
Eclipse plugins
Integrated into Java EE version of Eclipse Download free from http://www.eclipse.org/downloads/
Choose Eclipse IDE for Java EE Developers
Command-line tools
Windows and Unix
12
Uses of Axis2
Java-First (Bottom-Up) Services
Start with a normal Java class (POJO) Expose methods as Web Services Covered in this lecture
Axis2 Setup
Customized Java EE Training: http://courses.coreservlets.com/
Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6. Developed and taught by well-known author and developer. At public venues or onsite at your location.
Install
Unzip into directory of your choice
This tutorial uses C:\, resulting lti i in C C:\axis2-1.4 \ i 214
15
16
Idea
Take normal Java class (POJO)
public class Blah { public int doFoo(String arg) { ... } public String doBar(double arg) { ... } }
Shortcut
If you have previously made a Dynamic y Web Project in that workspace, you can just do New Dynamic Web Project
19
Public P blic methods will ill later become part of Web Service Ser ice
Added automatically when you make bottom-up Web Service
Lifecycle
Class will be reinstantiated on each request
So, So needs zero zero-argument argument constructor Fields are not persistent unless they are static
21
private static Map<String,String> symbolMap = new HashMap<String,String>(); static { for(String[] g company: p y companies) p { symbolMap.put(company[0], company[1]); } } private boolean isEmpty(String val) { return((val == null) || val.trim().equals("")); }
23
Press Finish
In future, you can deploy app normally (R-click (R click server server, Add and Remove Projects, select project, start server)
24
25
Click Services. For your service, you should see a list of the public methods, now exposed as Web Service operations.
Test Operations
http://host/app-name/services/service-name/op-name?param=value
26
View WSDL
http://host/app-name/ services/service-name service name ?wsdl
You can also click on service name in the listServices page shown earlier
27
Summary
Make dynamic Web project
File Fil New N Project P j t Web W b Dynamic D i W Web b Project P j t
Deploy
R-click server, Add and Remove Projects, select project, start server
Test
http://host/app-name/axis2-web/
28
Questions?
Customized Java EE Training: http://courses.coreservlets.com/
Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6. Developed and taught by well-known author and developer. At public venues or onsite at your location.