building enterprise applications with axis2
DESCRIPTION
Deepal Jayasinghe - WSO2 Inc. Ruchith Fernando - WSO2 Inc. Building Enterprise applications with Axis2. Aim of this Tutorial. Motivation Understanding and working with Axiom Learning Axis2 basics Understanding the deployment model Writing a service and deploying - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/1.jpg)
Building Enterprise applications with Axis2
Deepal Jayasinghe - WSO2 Inc.Ruchith Fernando - WSO2 Inc.
![Page 2: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/2.jpg)
2
Aim of this Tutorial• Motivation• Understanding and working with Axiom• Learning Axis2 basics• Understanding the deployment model• Writing a service and deploying • Writing a module and deploying• Working with new client API• Stub and skeleton generation• Axis2 and POJOs
![Page 3: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/3.jpg)
3
Motivation for Axis2• History of ASF SOAP engines
• Apache SOAP• Axis 1.x designed as a follow-on
• Why do we need a new SOAP engine?• Changes to the Web services landscape
• WS-A, WS-RM
• Performance• Parsers, Optimizing based on use
• Ease of use• Deployment of new capabilities, service
deployment
![Page 4: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/4.jpg)
4
AXIOM
![Page 5: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/5.jpg)
5
New XML Infoset Representation
• Known as AXIOM (AXIS Object Model)• NOT, Yet another XML object model
• API is more like a simplified DOM
• Fundamental difference ?• Objects are created “on demand” using a pull
model• Allows direct access to the underlying pull
stream with or without building the tree• Support for storing binary data
![Page 6: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/6.jpg)
6
New XML Infoset Representation
• API also provides a StAX parser interface at any element• Allows the event based navigation of the
OM tree.
![Page 7: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/7.jpg)
7
New XML Infoset Representation
AXI OM
Pull Event Stream
Push Event Stream
Pull Event Stream
Program m atic Creation
Push Event Stream
![Page 8: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/8.jpg)
8
New XML Infoset Representation
• In built binary storage support• Can store binary (unchanged)• Natively supports XOP/MTOM
• XOP? MTOM??
![Page 9: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/9.jpg)
9
AXIOM and Axis2
• AXIOM is the primary means of representing / manipulating the XML message inside Axis2
![Page 10: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/10.jpg)
10
Time to Dig Into Code.. • Code samples to explain AXIOM
• Serialization• De-serialization • XPath navigation
![Page 11: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/11.jpg)
11
Axis2 Basis
![Page 12: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/12.jpg)
12
Extensible Messaging Engine
Application
Transport
Ph
as
e
ZPh
as
e
YPh
as
e
X
XMLMessage
Engine
MessageReceiver
![Page 13: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/13.jpg)
13
Message processing stages
• There are three main stages• Transport Receiver
• Transport related processing
• Dispatching• Finding service and operation
• Message Receiver• Last handler of the chain
![Page 14: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/14.jpg)
14
Dispatching
• Two types of dispatching• Finding the corresponding descriptions• Finding the corresponding contexts
• Default dispatchers • AddressingBasedDispatcher• RequestURIBasedDispatcher• SOAPActionBasedDispatcher• SOAPMessageBodyBasedDispatcher
![Page 15: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/15.jpg)
15
Message Receiver• The last handler of the execution chain• MEP dependent (MEP ?? )• Does the actual business logic invocation• Ability to write custom Message Receivers• Supports Dependency injection !!• Some default Message Receivers
• RawXMLINOnlyMessageReceiver• RawXMLINOutMessageReceiver• RPC*MessageReceiver
![Page 16: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/16.jpg)
16
Message Exchange Patterns - MEP
• Describes the exchange pattern of SOAP messages per given operation.
• E.g.• In – Out• In Only• In – In – Out !
• WSDL 2.0 defines 8 standard MEPs.• Axis2 supports all inbound MEPs
![Page 17: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/17.jpg)
17
Contexts and Descriptions Hierarchy
• Descriptors keep static information• Information extracted from deployment
descriptors
• Contexts keep runtime information• This Information needs to be in
various scopes• Good to keep them separate!
![Page 18: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/18.jpg)
18
![Page 19: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/19.jpg)
19
Parameters and Properties• Parameters
• Defining a parameters • The “locked” attribute• Setting and getting• Parameter can be any object• getting the original OMElement from the parameter
• Properties• Difference between property and parameter• Accessing and retrieving property appropriately
![Page 20: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/20.jpg)
20
Deployment Model
![Page 21: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/21.jpg)
21
What's the Fuss with Deployment ?
• Axis 1.x deployment requires you to:• Either modify the XML files
• or
• Call the admin client• Add to the classpath• Restart the server
• For a beginner, a bit of headache
![Page 22: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/22.jpg)
22
New Deployment Model
• Archive based deployment• Bundle all together and drop in
• Directory based deployment (similar structure as archive )
• Hot Deployment • Archive file can contain;
• Class files• Third party libraries• Any other resources required by the service
![Page 23: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/23.jpg)
23
Axis2 Service
![Page 24: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/24.jpg)
24
Axis2 service• Can be deployed as an archive (.aar) file or as a
directory with all necessary resources• Isolated – separate Class loader
![Page 25: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/25.jpg)
25
Service Descriptor• Service configurations are given by the
services.xml• No need to have a WSDL around to be a valid service !!!
• Contains• ServiceClass parameter• Name spaces • Expose transports• Service scope• Operation
• actionMapping• MessageReceiver
• Modules to be engaged• Module configurations (module parameters)
![Page 26: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/26.jpg)
26
Service vs. Service Group
• Deploying multiple services together• Share data across services in a group• Maintain sessions across a service
group using contexts• Example use case of a Service Group
• Login• Do something• Log out
![Page 27: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/27.jpg)
27
Service scope
• Request scope• SOAP session scope
• Service group ID
• Transport session scope• Cookies
• Application scope
![Page 28: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/28.jpg)
28
Back to coding
• Writing services.xml• With single service• For a service group
• Writing service class • Explain dependency injection• Methods for life time management
• Co-relating WSDL file to a service
![Page 29: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/29.jpg)
29
Axis2 Module
![Page 30: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/30.jpg)
30
What is a module ?• Modules define the way of extending Axis2 • Encapsulates a specific functionality
(mostly a WS-* function)• e.g. Addressing module adds WS-Addressing
support
• Usually consists of a set of handlers• Modules are not hot deployable
• Because they change the overall behaviour of the system
![Page 31: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/31.jpg)
31
Inside an Axis2 Module• What does it contain ?
• Module descriptor : module.xml• (more in the next slide)
• Module implementation class• Handlers• Third party libraries
• Can be deployed as an archive file • Bundle all together and deploy
• Can be deployed as a directory as well• Isolated – separate class loader
![Page 32: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/32.jpg)
32
Module Descriptor<module name="addressing"> <Description>This is WS-Addressing implementation on Axis2. Currently we have implemented Submission version
(2004/08) and Proposed Recommendation. This is not complete as far as the fault handling is concerned. But we are working on that. </Description>
<inflow> <handler name="AddressingFinalInHandler" class="org.apache.axis2.handlers.addressing.AddressingFinalInHandler"> <order phase="PreDispatch"/> </handler> .............. </inflow>
<outflow> <handler name="AddressingOutHandler" class="org.apache.axis2.handlers.addressing.AddressingOutHandler"> <order phase="MessageOut"/> </handler> </outflow>
<Outfaultflow> ............. </Outfaultflow> <INfaultflow> ............. </INfaultflow></module>
![Page 33: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/33.jpg)
33
Availability and Engaging of Modules
• Concept of Availability• Presence of the module in the system
• Concept of Engaging• Activating the module• Can be done
• Per System• Per Service group• Per Service• Per Operation
![Page 34: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/34.jpg)
34
Back to Code ...
• Sample module with two handlers• Sample module with a module
implementation class• Explains
• engageNotify• init• shutdown
![Page 35: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/35.jpg)
35
New Client API
![Page 36: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/36.jpg)
36
ServiceClient
• Supports both blocking and non-blocking invocations models• Concept of callbacks for the client for
non- blocking case
• Can handle both transport dependent and transport independent asynchrony.
![Page 37: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/37.jpg)
37
Invocation patters
• sendRobust• fireAndForget• sendReceive• sendReceiveNonBlocking
![Page 38: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/38.jpg)
38
Operation Client
• Why do we need Operation client ?• Service Client has a set of operation
clients• If you are smart better to use
OperationClient
![Page 39: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/39.jpg)
39
What are options ?
• Why do we need options for the client ?
• What is included in options ?• Addressing information• SOAP action (wsa:action)• Transport data • Properties
![Page 40: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/40.jpg)
40
There's Nothing Like Code to Explain it !
• Simple Client written from scratch • Invoke using all the available patterns
• Working with operation client• An example dynamic client• How to use RPCServiceClient
![Page 41: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/41.jpg)
41
Code generation
![Page 42: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/42.jpg)
42
Code Generation• java org.apache.axis2.wsdl.WSDL2Code
Usage WSDL2Code -uri <Location of WSDL> :WSDL file location-o <output Location> : output file location-a : Generate async style code only. Default if off-s : Generate sync style code only. Default if off. takes precedence
over -a-p <package name> : set custom package name-l <language> : valid languages are java and csharp. Default is java-t : Generate TestCase to test the generated code-ss : Generate server side code (i.e. skeletons).Default is off-sd : Generate service descriptor (i.e. axis2.xml).Default is off.Valid
with –ss-u : unpack classes-ns2p : namespace to package mapping-d: choose databinding model – adb, xmlbeans, jibx none
![Page 43: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/43.jpg)
43
Generated Code : Client
• Structure• Stub• Empty Callback Handler• Databinding classes - Depends on the
selected databinding framework• Ant build file
![Page 44: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/44.jpg)
44
Generated Code : Service
• Structure• Skeleton• Custom Message Receiver• services.xml• WSDL file
![Page 45: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/45.jpg)
45
Code again...
• Codegen demonstration with the command line tool
• Generate skeleton , fill that and deploy
• Generate stub and invoke a service
![Page 46: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/46.jpg)
46
Advanced Topics
![Page 47: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/47.jpg)
47
REST
• Axis2 natively supports REST / pure XML/HTTP
• Switch on in axis2.xml• <parameter name="enableREST"
locked="false">true</parameter>• Off by default in current build• Uses Content-type / SOAP-Action
headers to differentiate SOAP vs REST
![Page 48: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/48.jpg)
48
POJOs
• Write POJO application• Creating service using POJO• Generate stub and invoke the service
![Page 49: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/49.jpg)
49
Axis2 web admin
• Nice tool to work with • Can manage Axis2 when its running
inside an application server• Ability to view handler chain ,
parameters etc …
![Page 50: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/50.jpg)
50
Resources and contribution• For more information and latest news
• http://ws.apache.org/axis2
• All the samples and presentation slides are available to download
• http://apache.org/~deepal/apacheconAsia06
![Page 51: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/51.jpg)
51
Questions ?
• [email protected] • Don’t forget to use [Axis2] prefix in the
subject
• IRC channel• #apache-axis
![Page 52: Building Enterprise applications with Axis2](https://reader035.vdocument.in/reader035/viewer/2022081519/568144cc550346895db1958e/html5/thumbnails/52.jpg)
52
Thank you !!!!!!