2. WEB SERVICES: INTRODUCTION
Web Service - Definition
• A s/w component stored on one computer &
accessed via method calls by an appln (or other
s/w component) on another computer over n/w.
• “a s/w s/m - to support interoperable m/c-to-
m/c interaction over a n/w”
3. How Web Service Works
• A SOA is a collection of services.
• services commn with each other & involve simple data
passing , call 2 or more services – coord some activity.
• service - is a function i.e., well-defined, self-contained
& does not depend on context or state of other
services.
• Web services commn. using such techno. as XML and
HTTP
• Simple Object Access Protocol (SOAP)
• XML-based protocol - allows web services & clients to
comm. in a platform-independent manner.
5. Web Services
• Example:
• Amazon, Google, eBay, PayPal &
• applns available to partners via web services
• Using WS, need less time develop new applns
& create innovative new applns
• 2 parties involved –
• web service provider and
• web service consumer.
7. Web Services
• Web Services is
– App to app commn.
– Interoperability b/w disparate systems.
– Comm over network.
– Exposed interface - platform indep & internal impl. is
abstract.
– Enables loosely coupled design.
– Open protocol is used for establishing comm
– Web services are self contained.
• 2 categories of web services
1. SOAP Web Service
2. RESTful Web Service
8. SOAP Web Service
• is a std protocol spec for msg xchg based on
XML.
• Comm b/w WS & client happens using XML
msgs.
• It defines rules for comm like what tags are
used in XML & their meaning.
9. RESTful Web Service
• RESTful web service uses archi - use HTTP or
similar protocols by restricting interface to use
std operations - GET, POST,… for HTTP.
10. Comparision
• REST services
Architectural style
Simply calls services via URL path
Lightweight – no extra xml markup
Easy to build – no toolkits required
• SOAP services
XML-based protocol
Invokes services by calling RPC method
Rigid – type checking, adheres to a contract
Development tools – WSDL Soap analyser tool,
oXygen XML
11. COMPONENTS OF WEB SERVICES
• Basic WS platform is XML + HTTP.
• All std WS work using following components
1. SOAP (Simple Object Access Protocol)
2. UDDI (Universal Description, Discovery and
Integration)
3. WSDL (Web Services Description Language)
12. COMPONENTS OF WEB SERVICES
• 1. SOAP
• simple & lightweight - xchg struct. & typed info. b/w
peers - decentralized, distri env. - using XML
• 2. WSDL
• is an xml file – describes WS in a m/c readable format.
• specify Port / Endpt – URL of the web service
• Input /output message format
• Security protocol i.e., to be followed (like https)
• 3. UDDI – Service Registry
• defines a std way to desc WS, reg WS – in a well-
known registry
13. Advantages Of Web Services
• Interoperability - distri. app that span diverse
h/w & s/w platforms
• Easy, widespread access to app thru firewalls
using Web protocols
• cross-plat, cross-lang data model (XML) - develop
heterogeneous distri. App
• Use of Std protocols & spec enables integ with
other msg S/m, Legacy S/m, etc
• Seamless Integ of B2B app
14. Java Web Services Basics
1. Remote machine or server
–computer - where WS resides
– client app access WS - send a method call over a n/w to remote
m/c – processes call & returns a resp over n/w to app
2. In Java, WS impl - as class that resides on a server
3. Publishing (deploying) a WS
– Making a WS available to receive client req
4. Consuming a web service
– Using WS from client app
Consuming WS (client) has 2 parts:
–obj of a proxy class - interact with WS
–client app that consumes WS by invoking methods on proxy obj
–proxy obj handles details of comm with WS on client‟s behalf
15. JAX-WS 2.0
• Req to & resp from WS transmit via SOAP
• Any client capable of generate & process SOAP
msg can interact with a WS, regardless lang in
which the WS is written
17. What are stubs?
• is a small prg routine – substitutes longer prg
to load later or located remotely.
• stub accepts req & then fwds it to the remote
procedure.
• When procedure complete its service –
returns results or other status to stub –
• Stub passes it back to prg that made the req.
18. Web Services Architecture
• Web Services involve 3 major roles
1. Service Provider
2. Service Registry
3. Service Consumer
• 3 major operations surround web services
1. Publishing – making a service available
2. Finding – locating web services
3. Binding – using web services
21. Creating, Publishing, Testing &
Describing Web Services
• @WebService annotation
– Indicates - class repre. WS
– Optional element name - is the name of the proxy
class i.e., generated for client
– Optional element serviceName – is name of the
class that client uses to obtain a proxy object.
23. @WebParam annotation
• Parameters of web methods r annotated -
@WebParam annotation
• @WebService annotation –used in generating
WSDL file.
• serviceName - same as WSDL ele. service
• name - same as WSDL element <portType name>
• endpointInterface - user defined name for Service
Endpoint Interface(SEI).
• portName – is element portName
• targetNamespace – is XML namesp of WSDL & XML
elements generated from WebService