A Practical Guide to Apache Axis2 Rajith Attapattu,
Rajith Attapattu : Toronto JUG Dec 05, About Me Senior Software Red Hat I hang around the following projects Apache Axis2, Qpid, Tuscany – Comitter Apache Synapse – Contributor SCA Binding Spec group Volunteer with Lanaka Software Found'n
Rajith Attapattu : Toronto JUG Dec 05, Examples
Rajith Attapattu : Toronto JUG Dec 05, Agenda Introduction Using POJOs with Axis2 Embedding Axis2 Integrating Axis2 How to debug/test a web service
Rajith Attapattu : Toronto JUG Dec 05, Axis2 From a 1000 feet
Rajith Attapattu : Toronto JUG Dec 05, What is Axis2 ? In simple terms a SOAP Engine Consumes and Produces messages Supports POX/HTTP + GET/POST Foundation for the Web Services Stack
Rajith Attapattu : Toronto JUG Dec 05, What is Axis2 ? Axis2 has an ecosystem around it Several WS projects extends Axis2 Built on top of Axis2 architecture Typically support a WS specification Ex: Apache Sandesha2, supports WS-RM
Rajith Attapattu : Toronto JUG Dec 05, What is Axis2 ? Supports key WS* specifications Axis2 (built in) : WS-Addressing, WS-Eventing Rampart Module : WS-Sec, WS-SC, WS-SP Rahas Module : WS-Trust Apache Sandesha2 : WS-RM Apache Kandula2 : WS-Cord'n, WS-AT, WS-BA Apache Neethi : WS-Policy Apache Synapse : Mediation + ESB
Rajith Attapattu : Toronto JUG Dec 05, Axis2 Highlights Hot Deployment Multiple Transport Support HTTP, JMS, SMTP, TCP Asynchronous Web Services WSDL Support (1.1 and 2.0) Extensible Module Architecture
Rajith Attapattu : Toronto JUG Dec 05, Axis2 Deployment Methods Deployed in a Servlet Container as WAR As a Standalone Sever Embedded in a another Application Inside a Spring Container Bundled inside another WAR file
Rajith Attapattu : Toronto JUG Dec 05, When a message is received..
Rajith Attapattu : Toronto JUG Dec 05, Message Receiver Simple Interface, good extention point Decouples the engine with MEPs Message Exchange Patterns IN_ONLY, OUT_ONLY, IN_OUT WSDL 2.0 defines 8 MEPs Supports Sync and Async operation styles
Rajith Attapattu : Toronto JUG Dec 05, Message Receiver We currently have RawXMLxxxMessageReceivers RPCxxMessageReceivers For example RawXMLInOnlyMessageReceiver RPCInOutAsyncMessageReceiver
Rajith Attapattu : Toronto JUG Dec 05, When a message is sent..
Rajith Attapattu : Toronto JUG Dec 05, AXIOM AXIs Object Model XML infoset representation Built on the StAX parser (JSR 173) Objects are built “On Demand”
Rajith Attapattu : Toronto JUG Dec 05, What Are Modules? Collection of Handlers & related resources Configuration (module.xml) Class files..etc Provides fine grained control of handlers Physical Isolation Logical Isolation WS-Addressing, WS-Security, WS-RM
Rajith Attapattu : Toronto JUG Dec 05, How Flexible are Modules? Concept of Availability Concept of Engaging Per System (Globaly) Per Service Group Per Service Per Operation
Rajith Attapattu : Toronto JUG Dec 05, Service Implementation Types POJOs Simple Java Beans that implement service logic Spring Beans Spring beans exposed as Web Services Generated Skeletons Custom generated from WSDL Raw XML OMElement based Interfaces Extensible Custom Message Receivers that replaces the standard ones
Rajith Attapattu : Toronto JUG Dec 05, Lets look at some code Axis2 supports both Schema first approach Code first approach WSDL2Code tool for Schema first Lets look at a very simple example Will introduce concepts as we go
Rajith Attapattu : Toronto JUG Dec 05, My First Axis2 Service Steps Lets write a simple Greeting Service POJO Write a deployment descriptor Package it and deploy
Rajith Attapattu : Toronto JUG Dec 05, Service Class
Rajith Attapattu : Toronto JUG Dec 05, Lets write the services.xml
Rajith Attapattu : Toronto JUG Dec 05, Package and Deploy Put the services.xml in the META-INF Create jar file Name it as GreetingService.aar Drop it in the Axis2 services directory Or upload through the Admin console
Rajith Attapattu : Toronto JUG Dec 05, Repository Structure Axis2 Repository | |___ Conf | | _ _axis2.xml | |___ modules | |__ addressing.mar | |___ services |__ greetingservice.aar
Rajith Attapattu : Toronto JUG Dec 05, Admin Console
Rajith Attapattu : Toronto JUG Dec 05,
Rajith Attapattu : Toronto JUG Dec 05, Repository If Deployed in a Servlet Container The repository is axis2/WEB-INF Any other way deployment method You can designate any location
Rajith Attapattu : Toronto JUG Dec 05, WS Client with Axis2 Supports both sync and async invocations Configure options via the Options class Important classes to note org.apache.axis2.client.Options org.apache.axis2.client.ServiceClient org.apache.axis2.client.OperationClient
Rajith Attapattu : Toronto JUG Dec 05, WS Client with Axis2
Rajith Attapattu : Toronto JUG Dec 05, Async Client Invocation
Rajith Attapattu : Toronto JUG Dec 05, Pure Asynchrony
Rajith Attapattu : Toronto JUG Dec 05, POJO Support How to POJO with Axis2 JSR 181 support for annotations
Rajith Attapattu : Toronto JUG Dec 05, Warning Contract (Schema/WSDL) first is the recomended approach Don't just expose object heirachies Think message oritented not object oriented
Rajith Attapattu : Toronto JUG Dec 05, How to POJO with Axis2 Can add services programaticaly Quick and easy, good for testing Spport via the RPC Message Receiver Client side support via RPCClient Lets look at the simple example
Rajith Attapattu : Toronto JUG Dec 05, POJO Example
Rajith Attapattu : Toronto JUG Dec 05, Configuration Context
Rajith Attapattu : Toronto JUG Dec 05, JSR 181 Support Based on the Annotations framework Annotates POJOs as Web Services Part of JAX-WS Still work
Rajith Attapattu : Toronto JUG Dec 05, Sample Annotated POJO
Rajith Attapattu : Toronto JUG Dec 05, Integrating with Axis2
Rajith Attapattu : Toronto JUG Dec 05, Integrate with Axis2 How can I embed Axis2 Spring Integration Hibernate with Axis2
Rajith Attapattu : Toronto JUG Dec 05, How can I embed Axis2? Embeding Axis2 in my application? Embeding Axis2 in my WAR file?
Rajith Attapattu : Toronto JUG Dec 05, Embedding Axis2 in my Application You don't always need to deploy Axis2 in a servlet container. You can run Axis2 standalone You can also embed Axis2 in your App
Rajith Attapattu : Toronto JUG Dec 05, Embedding in my App Just drop the Axis2 jars in your classpath Choice of JMS, HTTP, TCP or SMTP Lets look at an example
Rajith Attapattu : Toronto JUG Dec 05, Using SimpleHTTPServer Steps Create a ConfigurationContext Initialize the SimpleHTTPServer Start the server
Rajith Attapattu : Toronto JUG Dec 05, Using SimpleHTTPServer
Rajith Attapattu : Toronto JUG Dec 05, Embedding in a WAR file A good appraoch if you want to bundle Axis2 with your Web App Simply drop your jars in the lib folder Add Axis2 servlet to your web.xml
Rajith Attapattu : Toronto JUG Dec 05, Embedding in a WAR file Can I bundle my services in the WAR file? You can add the services in the exploded format under the WEB-INF Or you can add services programaticaly
Rajith Attapattu : Toronto JUG Dec 05, Embedding in a WAR file Steps Drop jars in the WEB-INF/lib folder Add Axis2 servlet in the web.xml Add your services In 'exploded format' Programatically
Rajith Attapattu : Toronto JUG Dec 05, Add AxisServlet to you web.xml
Rajith Attapattu : Toronto JUG Dec 05, Exploded Format
Rajith Attapattu : Toronto JUG Dec 05, Spring Integration Simple and easy configuration Expose Spring beans as Web Services Plugpoint to leverage Spring Lets look at a Simple example
Rajith Attapattu : Toronto JUG Dec 05, Simple Use Case for Spring Steps Define a service interface Implement your service interface Write your WebService that uses the service Inteface
Rajith Attapattu : Toronto JUG Dec 05, Define the Service Interface
Rajith Attapattu : Toronto JUG Dec 05, Service Implementation1
Rajith Attapattu : Toronto JUG Dec 05, Service Implementation2
Rajith Attapattu : Toronto JUG Dec 05, Writing the Web Service
Rajith Attapattu : Toronto JUG Dec 05, Configuration & Deployment Steps Write your spring config file Write the services.xml Deploy in a servlet environment Deploy in a non-servlet environment
Rajith Attapattu : Toronto JUG Dec 05, Spring Configuration
Rajith Attapattu : Toronto JUG Dec 05, Servlet Container - web.xml
Rajith Attapattu : Toronto JUG Dec 05, Servlet Container - services.xml
Rajith Attapattu : Toronto JUG Dec 05, Non-Servlet Env - services.xml
Rajith Attapattu : Toronto JUG Dec 05, Non-Servlet Env
Rajith Attapattu : Toronto JUG Dec 05, Hibernate with Axis2 Poped up in the list a couple of times Don't need to do anything special Add hibernate jars in your classpath
Rajith Attapattu : Toronto JUG Dec 05, JAX-WS Status Initial JAX-WS code drop from IBM JAX-WS component is built on top of Axis2 Target completion date is TBD
Rajith Attapattu : Toronto JUG Dec 05, How To Debug a Web Service Use remote debug to check you service Very useful to see what goes on the wire TCPMon from WS Commons is a good tool SOAP Monitor comes bundled with Axis2
Rajith Attapattu : Toronto JUG Dec 05, Remote Debugging Add the following JVM arguments This will start the server in debug mode Use Eclipse or IDEA (refer documentation)
Rajith Attapattu : Toronto JUG Dec 05, Using TCPMon Logs SOAP messages that passes through Can act as an intermediary Can act as a request sender Can act as a proxy Can simulate slow connections
Rajith Attapattu : Toronto JUG Dec 05, Using SOAP Monitor Axis2 module called soapmonitor.mar Engage globaly in axis2.xml Messages are forwarded to a SOAP monitor Can view the data via an Applet Disable by default for security reasons
Rajith Attapattu : Toronto JUG Dec 05, Resources
Rajith Attapattu : Toronto JUG Dec 05, Questions?
Rajith Attapattu : Toronto JUG Dec 05, Thank you
Rajith Attapattu : Toronto JUG Dec 05, Feedback is appreciated