intro to apache axis l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Intro to Apache Axis PowerPoint Presentation
Download Presentation
Intro to Apache Axis

Loading in 2 Seconds...

play fullscreen
1 / 42

Intro to Apache Axis - PowerPoint PPT Presentation


  • 238 Views
  • Uploaded on

Intro to Apache Axis. Siva Jagadeesan sivajag@hotmail.com. About Me. I am a Java Consultant working in a project for Deloitte Consulting My fields of Expertise J2EE Technologies Java tools for Extreme Programming (Ant, JUnit etc) My fields of Interest Web Services J2ME

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Intro to Apache Axis' - jana


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
intro to apache axis

Intro to Apache Axis

Siva Jagadeesan

sivajag@hotmail.com

about me
About Me
  • I am a Java Consultant working in a project for Deloitte Consulting
  • My fields of Expertise
    • J2EE Technologies
    • Java tools for Extreme Programming (Ant, JUnit etc)
  • My fields of Interest
    • Web Services
    • J2ME
    • Aspect Oriented Programming
agenda
Agenda
  • Web Services Basics
  • Intro to Apache Axis
outline
Outline
  • Web Services Basics
    • What is Web Service?
    • Web Services Architecture
    • XML Messaging
      • XML-RPC
      • SOAP
    • What is WSDL?
    • Development plan for Service Requestor
    • Development plan for Service Provider
outline5
Outline
  • Intro to Apache Axis
    • What is Apache Axis?
    • Architecture of Apache Axis
    • Features of Apache Axis
    • Installing Apache Axis
    • Publishing Web Service through Apache Axis
    • Walkthrough of deploying and accessing a simple web service using Apache Axis
what is web service
What is Web Service?

A Web Service is any service that

  • is available over the web
  • uses standardized XML messaging
  • is OS and Programming language independent
web services architecture
Web Services Architecture

There are two ways we can view Web Services

architecture

  • Web Service Roles
  • Web Service Protocol Stack
web service roles
Web Service Roles

There are three major roles

Logically Centralized directory of services

Service

Registry

2) Discover services

1) Register service

Service

Provider

Service

Requestor

3) Invoke service

Provider of the Web Service

Consumer of the Web Service

web service protocol stack
Web Service Protocol Stack

Discovery UDDI

Responsible for centralizing services

DescriptionWSDL

Responsible for describing the public interface to a specific web service

XML MessagingXML-RPC,SOAP,XML

Responsible for encoding messages in common XML format

Transport HTTP,SMTP,FTP,BEEP

Responsible for transporting messages

xml messaging
XML Messaging

There are two ways of XML Messaging

  • XML-RPC
  • SOAP
what is xml rpc
What is XML-RPC ?
  • is a simple protocol that uses XML messages to perform RPC
  • Request are encoded in XML and send via HTTP
  • Response are encoded in XML and received via HTTP
  • is a easiest way to get started with web services
sample xml rpc request
Sample XML-RPC Request

<methodCall>

<methodName>

com.agram.sayHello

</methodName>

<params>

<param>

<value>Java</value>

</param>

</params>

</methodCall>

sample xml rpc response
Sample XML-RPC Response

<methodResponse>

<params>

<param>

<value>

<string>Hello Java</string>

</value>

</param>

</params>

</ methodResponse >

what is soap
What is SOAP?
  • Simple Object Access Protocol
  • SOAP is slightly more complicated than the XML-RPC
  • SOAP extended XML-RPC
  • It uses XML namespaces and XML Schemas.
soap message
Envelope is like a wrapper for content

Header is a optional element that could contain control information

Body element includes requests and responses

Body element will include a Fault element in the event of an error

SOAP Message

SOAP Message

Envelope

Header

Body

sample soap request
Sample SOAP Request

<SOAP-ENV:Envelope

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

      xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/

     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<SOAP-ENV:Body>    

<ns1:sayHello

xmlns:ns1="http://agram.com/">

      <name xsi:type="xsd:string">Java</name>

</ns1:sayHello>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

sample soap response
Sample SOAP Response

<SOAP-ENV:Envelope

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

      xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/

     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<SOAP-ENV:Body>    

<ns1:sayHelloReponse

xmlns:ns1="http://agram.com/">

<result xsi:type="xsd:string">Hello Java</result> </ns1:sayHelloResponse>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

what is wsdl
What is WSDL?
  • Web Services Description Language
  • Has 6 major elements
    • definitions – defines the name of the web service
    • types – describes all the data types that will be transmitted
    • message – defines the name of the message that will be transmitted
    • portType – defines the operations
    • binding – defines how the message will be transmitted
    • service – defines where the service is located
development plan for service requestor
Development plan for Service Requestor

1) Find web service via UDDI

2) Retrieve service description file

3) Create XML-RPC or SOAP client

4) Invoke remote service

development plan for service provider
Development plan for Service Provider

1) Create the core functionality

2) Create XML-RPC or SOAP service wrapper

3) Create service description file

4) Deploy service

5) Register new service via UDDI

what is apache axis
What is Apache Axis?

“Axis is essentially a SOAP engine – a

framework for constructing SOAP

processors such as clients , servers,

gateways etc”

- Axis Website

architecture of apache axis23
Architecture of Apache Axis
  • Admin Sub-system

handles administration and configuration of the server

  • Service Sub-system

implements the RPC exchange protocol

  • Provider Sub-system

is the interface between Axis server and the external component methods that are to be exposed as webservice

  • Transport Sub-system

receives and delivers the message from the service sub system

  • Encoding Sub-system

manages encoding/decoding and serilization/deserilization between XML data types and Java Classes

  • Message Sub-system

defines the structure of the different elements of a SOAP message and provides functionality for binding and parsing the different elements of these messages

features of apache axis
Features of Apache Axis
  • Successor to Apache SOAP
  • It can run as a standalone server or as an a server that plugs into Servlet engine like Tomcat
  • Automatic WSDL generation for deployed services
  • Java2WSDL – to generate WSDL from Java interface
  • WSDL2Java – to generate Java classes from WSDL
  • Easy deployment
  • Uses JAX-RPC API
installing apache axis
Installing Apache Axis

1) Download Axis Distribution archive from

http://xml.apache.org/axis/

- Axis distribution archive contains a web application ( webapps/axis/ directory) for hosting an Axis Server in a web container like Tomcat

installing apache axis cont
Installing Apache Axis (Cont)

2) Deploy Axis Server in the Tomcat 4.X server

a) Copy Axis Web application (webapps/axis directory) to $TOMCAT_HOME/webapps

b) Copy jaxrpc.jar (that is provided with Axis distribution) and xerces.jar ( or any other XML parser) to $TOMCAT_HOME/common/lib

jaxrpc.jar and xerces.jar includes classes with “java” and “javax” packages and Tomcat does not authorize to load any classes in that package from WEB-INF/ lib directory of the web application.

installing apache axis cont27
Installing Apache Axis (Cont)

3) Configure the environment by including these libraries in the CLASSPATH

- log4j-core.jar

- commons-logging.jar

- wsdl4j.jar

- jaxrpc.jar

- tt.bytecode.jar

- xerces.jar ( or any other XML Parser)

validating the installation
Validating the Installation
  • Start the Tomcat Web Server
  • Goto http://localhost:8080/axis/

- you should be able to see Apache-Axis start page

- if you did not , then the axis is not correctly installed or the web server is not running

  • Goto http://localhost:8080/axis/happyaxis.jsp

- this test page verifies whether all the needed and optional libraries are present.

- Axis will not perform properly until all the needed libraries are present.

publishing web service through apache axis
Publishing Web Service through Apache Axis

The two ways we can publish a web service

with Axis are,

  • Instant Deployment – Java Web Service (JWS)
  • Custom Deployment – Using Web Service Deployment Descriptor ( WSDD)
the steps we will walkthrough
The steps we will walkthrough
  • Code – code a simple HelloWorld java class that we want to expose as web service
  • Java2WSDL – Generate the WSDL file for the given HelloWorld Interface
  • WSDL2Java – Generate the Server side wrapper class and stubs for easy client access
  • Deploy – deploy the service to apache axis
  • Client – code a simple client that access our HelloWorld Web Service
step 1 code
Step 1: Code

HelloWorld.java

package helloworld;

public interface HelloWorld {

public String sayHello( String name);

}

step 1 code cont
Step 1: Code (Cont)

HelloWorldImpl.java

package helloworld;

public class HelloWorldImpl implements HelloWorld {

public String sayHello( String name){

if(name == null)

return “Hello Everyone”;

else

return “Hello “ + name;

}

}

step 2 java2wsdl
Step 2: Java2WSDL

This command will generate the WSDL that

Conforms to our interface

% java org.apache.axis.wsdl.Java2WSDL

-o hello.wsdl

-l http://localhost:8080/axis/services/helloworld

-n urn:helloworld

-p“helloworld" urn:helloworld

helloworld.HelloWorld

Parameters description

-o = Name of the output

-l = URL of the web Service

-n = Target Namespace for the WSDL

-p = Map Java package to namespace

Fully Qualified Class Name

step 3 wsdl2java
Step 3: WSDL2Java

This command will generate the wrapper code for

deploying the service, as well as client stubs for

accessing it.

% java org.apache.axis.wsdl.WSDL2Java

-o .

-d Session

-s

-p helloworld.gen

hello.wsdl

Parameters description

-o = Base output Directory

-d = Scope of deployment

-s = To generate Server-side code too

-p = Package to place the code

Name of the WSDL

step 3 wsdl2java36
Step 3: WSDL2Java

These are the codes that will get generated

  • HelloWorldSoapBindingImpl.java – This is the implementation code for the Web Service
  • HelloWorld.java – This is the remote interface
  • HelloWorldService.java – This is the service interface
  • HelloWorldServiceLocator.java – Helper class to retrieve handler to service
  • HelloWorldSoapBindingSkeleton.java – Server-side skeleton code
  • HelloWorldSoapBindingStub.java – Client side stub
  • deploy.wsdd – axis deployment descriptor
  • undeploy.wsdd – deployment descriptor to undeploy the web services from the Axis System
step 3 wsdl2java37
Step 3: WSDL2Java

HelloWorldSoapBindingImpl

package helloworld.gen;

public class HelloWorldSoapBindingImpl implements helloworld.gen.HelloWorld

{

public String sayHello(String str0) throws java.rmi.RemoteException {

}

}

import helloworld.HelloWorldImpl;

HelloWorldImpl helloWorld = new HelloWorldImpl();

return helloWorld.sayHello(str0);

step 4 deploy
Step 4: Deploy
  • Compile the Service Code

% javac helloworld\gen\*.java

  • Package the code for Axis

% jar cvf hello.jar helloworld/*.class helloworld/gen/*.class

% mv hello.jar $TOMCAT_HOME/webapps/axis/WEB-INF/lib

  • Deploy the Service using WSDD

% java org.apache.axis.client.AdminClient deploy.wsdd

<admin> Done processing </Done>

step 5 client
Step 5: Client

package helloworld;

Import helloworld.gen.*;

public class HelloWorldTester {

public static void main(String [] args)

throws Exception

{

// Make a service

HelloWorldService service = new HelloWorldServiceLocator();

// Now use the service to get a stub to the service

helloworld.gen.HelloWorld hello = service.getHelloWorld();

// Make the actual call

System.out.println( hello.sayHello(“Java Gurus”) );

}

}

summary
Summary
  • Web Service
    • Roles in Web Services
    • Web Services Protocol Stack
    • Different ways of XML Messaging
    • Development plan for Service Requestor and Provider
  • Axis
    • Architecture of Axis
    • Features of Apache Axis
    • Installing Apache Axis
    • Different ways of deploying Web Service with Axis
    • Deploying and accessing a simple web service using Apache Axis
resources
Resources
  • JAX-RPC home - http://java.sun.com/xml/jaxrpc/index.html
  • Web Services & Java home - http://java.sun.com/j2ee/webservices/index.html
  • Java Web Services tutorial - http://java.sun.com/xml/docs.html#tutorials
  • Apache Axis - http://xml.apache.org/axis/index.html
  • SOAP 1.1 - http://www.w3.org/TR/SOAP
  • WSDL 1.1 - http://www.w3.org/TR/wsdl
questions feedbacks
Questions/Feedbacks?

Contact me at

sivajag@hotmail.com