Apache
Axis2
Web
Services
2nd Edition
Create
secure,
reliable,
and
easy-to-use
web services
using Apache
Axis2
Deepal
Jayasinghe
Afkham Azeez
rpAfi/jl
open
source
I
I
I
I
community experiencedistilledv.?
w
PUBLISHING
Table
of
Contents
Preface 1
Chapter
1:Apache
Web Services and Axis2 7Service Oriented Architecture (SOA) 8
Web service overview 10 How do organizations move into webservices? 11 Web services model 12
Web services standards 13
XML-RPC 14
SOAP 14
Web ServicesAddressing
(WS-Addressing)
15 Service description 15 Web ServicesDescription
Language (WSDL) 16Web services
lifecycle
16Apache
Web Service stack 18WhyAxis2?
19Downloading and
installing Apache
Axis2 21 Binarydistribution 22 WAR distribution 23 Source distribution 25 Document distribution 25 JARdistribution 25 Summary 26Chapter
2:Looking
inside Axis2 27Axis2 architecture 27
Core modules 28
XML processing model 30
SOAP
processing
model 30TableofContents
Deployment
model 33 ClientAPI 34 Transports 36 Other modules 36 Codegeneration
37 Databinding
37Extensible nature of Axis2 38
Service extension orthe module 38 Custom
deployers
39Message
receivers 39Summary
39Chapter
3: Axis 2 XML Model(AXIOM)
41Overview of AXIOM and its features 41
What is pull parsing? 42
Architecture 43
Working
with AXIOM 43Creating
Axiom 44CreatingAxiom from an
input
stream 44CreatingAxiomusing astring 45
CreatingAxiomprogrammatically 46
Adding
child nodes and attributes 47Working
with OM namespaces 48Working
with attribute 48TraversingtheAxiomtree 48
Serialization 49
Advanced operations with Axiom 51
Xpath navigation 51
Accessingthepullparser 52
Axiom and SOAP 52
Summary
54Chapter
4: Execution Chain 55Handler 56
Writing a simple handler 57
Phase 58
Types
ofphases
60Globalphases 60
Operation phases 62
Phase rules 62
Characterizing a phase rule 62
Phasename 63
phaseFirst 63
before 63
after 64
after and before 64
Invalidphase rules 64
Flow 65
Module engagementand
dynamic
execution chain 66Special
handlers in the chain 67Transportreceiver 67
Dispatchers 67
Messagereceiver 68
Transportsender 69
Summary
69Chapter
5:Deployment
Model7±
What is new in Axis2 deployment? 72
Hot
deployment
andhot update 74Hot
deployment
74Hot
update
75Repository
75Change in the way ofdeploying handlers
(modules)
76 Deploymentdescriptors
77Global
descriptor
or axis2.xml 78Service
descriptor (services.xml)
78Module
descriptor
ormodule.xml 79Available
deployment
options 79Archive-based
deployment
80Directory-based deployment
80Deploying
a serviceprogrammatically
80POJO
deployment
81Deploying
and running a service in one line 83Summary 84
Chapter
6: Information Model 85Axis2staticdata 86
AxisConfiguration
88Parameters 89
MessageReceiver 90 MessageFormatters and MessageBuilders 91 TransportReceiverand TransportSender 91
Flows and
phaseOrder
92AxisModule 93
Service description
hierarchy
94TableofContents AxisService 95 AxisOperation 95
AxisMessage
96 Axis2contexts 96 ConfigurationContext 97 ServiceGroupContext 98 ServiceContext 98OperationContext
98MessageContext
99 Summary 99Chapter 7:
Writing
an Axis2 Service 101Creating aweb service 102 The code firstapproach 104
Single
class POJO approach 104POJOs with
packages
106Deploying services
using
a service 108Writingthe services.xml file 108
Serviceimplementationclass 109
Specifyingthe message receiver 109
Creating a service archive file 110
Different ways of specifying message receivers 110
Service group and
single
service 113Adding
third-party
resources 114Service WSDL and schemas 114
Contract firstapproach-starting from the WSDL 116
Generating code 116
Filling
in theservice skeleton 117Running
the antbuild file 117Summary 117
Chapter
8:Writing
anAxis2 Module 119Brief history of the Axis2 module 120
Module concept 120
Module structure 121 Moduleconfigurationfile(module.xml) 122 Handlers andphaserules 123 Moduleimplementationclass 125
Writing
the module.xml file 128Deployingandengagingthe module 129
Advanced module.xml 132
WS-Policy 132
Endpoints 133
Summary
134Chapter
9: The Client API 135Webservice client 136
Blocking
and non-blockinginvocation 136Looking
into Axis2 clientAPI 137ServiceClientAPI 137 ServiceClient with working samples 140
Working
with the OperationClient 147Summary
150Chapter
10: Session Management 151Stateless natureof Axis2 152 Theavailable type of sessions in Axis2 153
Session
initializing
and sessioninvalidating
155Java reflection 155 Usingthe optional interface 156 Accessing
MessageContext
156 Requestsession scope 157SOAPsession scope 158
Transport
session scope 162Option
1: Usingthe browser 162Option
2: Usingthe service client 163Application scope 163 Managing sessions
using
ServiceClient 164Summary
164Chapter
11:Developing
JAX-WS Web Services 165Writing
asimpleJAX-WS web service 166JAX-WS annotations 166 JSR 181
(Web
ServiceMetadata)
annotations 167javax.jws.WebService 167 javax.jws.WebMethod 169 javax.jws.OneWay 170 javax.jws.WebParam 171 name 171 targetNamespace 172 mode 172 header 172 partName 172 javax.jws.WebResult 172 javax.jws.soap.SOAPBinding 174
TableofContents
JSR 224
(JAX-WS)
annotations 175javax.xml.ws.BindingType 175
javax.xml.ws.RequestWrapperandjavax.xml.ws.ResponseWrapper 176
javax.xml.ws.ServiceMode 177 javax.xml.ws.WebEndpoint 177 javax.xml.ws.WebFault 178 javax.xml.ws.WebServiceClient 178 javax.xml.ws.WebServiceProvider 179 javax.xml.ws.WebServiceRef 180 JSR 222 (JAXB) annotations 180 javax.xml.bind.annotation.XmlRootElement 181 namespace 181 name 181 javax.xml.bind.annotation.XmlAccessorType 182 javax.xml.bind.annotation.XmlElement 182 name 183 namespace 183 JSR 250(Common Annotations) 183 javax.annotation.Resource 183 javax.annotation. PostConstruct 184
javax.annotation.PreDestroy
184Code first service developmentwith JAX-WS 185
Contract first
development
with JAX-WS 188Client-sideJAX-WS 193
TheDispatchclient 194
TheDynamicProxy client 196
MTOM with JAX-WS Services 196
Asynchronous invocation ofJAX-WS services 198
Pollingmodel 198
Callback model 198
Summary 200
Chapter 12; Axis2
Clustering
201Setting up a
simple
Axis2 cluster 202Writing
ahighly
available clusterableweb service 203
Stateless Axis2 Web Services 204 Setting up afailover cluster 204 Increasing horizontal
scalability
205 Setting up andconfiguring
Axis2 clusters in production 206Clustering
agent 206Clustering
agent parameters 206Avoidlnitiation 207
membershipScheme 207
of synchronizeAII 208 maxRetries 208 mcastAddress 208 mcastPort 208 mcastFrequency 208 memberDropTime 208 mcastBindAddress 209 localMemberHost 209 localMemberPort 209 preserveMessageOrder 209 atmostOnceMessageSemantics 209 properties 210 State management 210 Node management 211
Group
management 211 Static members 212 Fullconfiguration
212Membership
schemes 214 Static membership 214 Dynamicmembership
216 Hybridmembership
216 Cluster management 218Highly
available loadbalancing
220TheAxis2 clustering managementAPI 220
org.apache.axis2.clustering.ClusteringAgent
221org.apache.axis2.clustering.state.StateManager
222org.apache.axis2.clustering.management.NodeManager
223org.apache.axis2.clustering.management.GroupManagementAgent
223Summary
223Chapter
13: EnterpriseIntegration
Patterns 225Apache Synapse 226
WS02 ESB 227
OpenESB 230
Protocol bridging 230
External authentication and authorization 231 Dynamic
routing
combined with auditing 233 Event DrivenArchitecture (EDA)withMaster DataManagement
(MDM) forIntegrating Legacy
Systems 234Event DrivenArchitecture (EDA) 234
Master Data
Management (MDM)
235Adaptor layer 236
Integration server 236
TableofContents
Registry
237Push and pull 237
Fault tolerant
autoscaling
with dynamic load balancing 239References 240
Summary
240Chapter
14: Axis2Advanced Features andUsage
243RepresentationalState Transfer
(REST)
244 Features ofREST 244REST services in Axis2 244
RESTweb service with GET and POST 245
Message
Transmission Optimization Mechanism(MTOM)
247By
value 247By reference 247
MTOM on the client side 249
MTOM on the service side 250
Axis2
configurator
251Deploying
Axis2 in various application servers 252Asynchronous
webservices with Axis2 254Client side
asynchronous
254 Application-level asynchronous support 257Transports-level
asynchronoussupport
258Summary
259Chapter
15: Building a Secure Reliable Web Service 261Reliableweb services 262
Sampleservice 263
One wayinvocation 264
Request-replyinvocation 266
Managing
sequences 268Creatingasequence withoutsendinga message 269
Terminateasequence 269
Secure webservices 269
Sampleservice 270
Writingthepasswordcallback 270
Creating
the policyelement 271Generatingclient stubs 273
Invokingtheservicewithoutsecurity 273
Invokingthe service withsecurity 273