View
217
Download
0
Embed Size (px)
8/6/2019 Web Service Using JAX WS
1/59
Java Web Service
8/6/2019 Web Service Using JAX WS
2/59
Objective
What Is a Web Service? Identifying Web Service Standards
JEE Web Service APIs
Using Java API for XML based-WS API (JAX-WS) Developing a Web Service by Using the Bottom-
Up Approach
Invoking the Web Service with a Java Client
Application
Developing a Web Service by Using the Top-
Down Approach
8/6/2019 Web Service Using JAX WS
3/59
What is Service ?
A service is a behavior that is provided by a
component for use by any other component
based only on the interface contract.
A service has a network-addressable interface.
A service may be dynamically discovered and
used.
8/6/2019 Web Service Using JAX WS
4/59
8/6/2019 Web Service Using JAX WS
5/59
8/6/2019 Web Service Using JAX WS
6/59
8/6/2019 Web Service Using JAX WS
7/59
8/6/2019 Web Service Using JAX WS
8/59
Service-oriented Architecture
SOA is a design and a way of thinking about building s/w components.
8/6/2019 Web Service Using JAX WS
9/59
Benefits of SOA
Better reuse
Build new client functionality on top of existing
Business Services
Well defined interfaces
Make changes without affecting clients
Easier to maintain
Changes/Versions are not all-or-nothing
Better flexibility
8/6/2019 Web Service Using JAX WS
10/59
What is aWeb Service?
In simpler terms
Software that performs a task.
Sits on a network so other systems can talk toit (most often SOAP over HTTP).
Has a defined, published interface (viaWSDL).
Is pla
tforma
nd la
ngua
ge independent. Typically uses XML.
8/6/2019 Web Service Using JAX WS
11/59
8/6/2019 Web Service Using JAX WS
12/59
8/6/2019 Web Service Using JAX WS
13/59
Web service standards
8/6/2019 Web Service Using JAX WS
14/59
8/6/2019 Web Service Using JAX WS
15/59
Web services programming stack.
Web service stack is a collection of
standardized protocols and application
programming interfaces (APIs) that lets
individuals and applications locate and utilize
Web services.
8/6/2019 Web Service Using JAX WS
16/59
8/6/2019 Web Service Using JAX WS
17/59
Simple Object Access Protocol
SOAP is a lightweight protocol for exchange of information in a
decentralized, distributed environment.
It is an XML based protocol that consists of three parts:
1. SOAP envelope that defines a framework for describing what is in amessage
and how to process it.
2. SOAP encoding rules for expressing instances ofapplication-defined data types.
3. SOAP for representing remote procedure calls and responses.
8/6/2019 Web Service Using JAX WS
18/59
8/6/2019 Web Service Using JAX WS
19/59
8/6/2019 Web Service Using JAX WS
20/59
8/6/2019 Web Service Using JAX WS
21/59
8/6/2019 Web Service Using JAX WS
22/59
8/6/2019 Web Service Using JAX WS
23/59
SOAP Envelope the primary container
root element of the message using the XML namespace
http://schemas.xmlsoap.org/soap/envelope/ (As per SOAP 1.1spec.)
SOAP Header first immediate child element of a SOAP envelope
zero or more optional child elements mustUnderstand attribute
represents a transaction semantics entry
provide mechanisms to extend
defining high-level functionalities such as security, transactions,priority, and auditing
8/6/2019 Web Service Using JAX WS
24/59
SOAP Header
The Header element is encoded as the first immediate child element of the
SOAP Envelope XML element. All immedia
te ch
ild elements of th
e Hea
derelement are called header entries.
The encoding rules for header entries are as follows:
1. A header entry is identified by its fully qualified element name, which
consists of the namespace URI and the local name.
2. The SOAP encodingStyle attribute MAY be used to indicate the encoding style
used for the header entries.
3. The SOAP mustUnderstand attribute.
5
8/6/2019 Web Service Using JAX WS
25/59
SOAP Body SOAP envelopes child element
one or more optional SOAP body block entries
mandatory processing information or the payload intended for thereceiver
Body block can contain RPC method and its parameters
Target application (receiver) specific data
SOAP fault for reporting errors and status information
SOAP Fault error and/or status information
elements to define the error and status Faultcode (VersionMismatch, MustUnderstand, Client, Server)
Faultstring, Faultactor, Detail
8/6/2019 Web Service Using JAX WS
26/59
SOAP mustUnderstand the processing of a SOAP header block is mandatory
or optional at the target SOAP node
SOAP Attachments
An XML format and any data format (can be ASCII orbinary)
8/6/2019 Web Service Using JAX WS
27/59
Examples of SOAP Messages
SOAP Message Embedded in HTTP Request
POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "Some-URI"
L&T
8/6/2019 Web Service Using JAX WS
28/59
SOAP Message Embedded in HTTP Response
HTTP/1.1 200 OKContent-Type: text/xml; charset="utf-8"Content-Length: nnnn
34.5
8/6/2019 Web Service Using JAX WS
29/59
SOAP Communication
SOAP RPC remote procedural call-based synchronous
communication tightly coupled communication model based on
requests and responses.
SOAP Messaging
document-driven communication Using synchronous and asynchronous messaging
loosely coupled communication model based onmessage notification and the exchange of XMLdocuments
8/6/2019 Web Service Using JAX WS
30/59
8/6/2019 Web Service Using JAX WS
31/59
Web service Description Language -WSDL
Interface Definition Language (IDL) service based on XML that
defines the service interface and its implementation characteristics.WSDL document contains following (W3C spec):
Types a container for data type definitions using some type system
(suchas XSD).
Message an abstract, typed definition of the data being communicated.
Oper
ation
ana
bstra
ct description ofa
na
ction supported by th
eservice.
Port Typean abstract set of operations supported by one or more
endpoints.
Binding a concrete protocol and data format specification for a
particular port type.
Port a single endpoint defined as a combination ofa binding and anetwork address.
Service a collection of related endpoints.
8/6/2019 Web Service Using JAX WS
32/59
8/6/2019 Web Service Using JAX WS
33/59
The main structure of a WSDL document :
definition of types........
definition ofamessage....
definition ofa port.......
definition ofa binding....
8/6/2019 Web Service Using JAX WS
34/59
WSDL Ports
The element is the most importantWSDL element.
It describes a web service, the operations that can be performed, and the
messages that are involved.
WSDL Messages
The element defines the data elements ofan operation.
Eachmessage can consist of one or more parts. The parts can be compared
to the parameters ofa function call in a traditional programming language.
WSDL Types
The element defines the data types that are used by the web
service.
For maximum platform neutrality, WSDL uses XML Schema syntax to define
data types.
WSDL Bindings
The element defines the message format and protocol details for
each port.
8/6/2019 Web Service Using JAX WS
35/59
UDDI
The Universal Description, Discovery, and Integration (UDDI) specifications
define how to publishand discover information about services in a UDDI-conforming registry.
The UDDI schema identifies the types of XML data structures that comprise an
entry in the registry for a service.
UDDI registry as a "Yellow Pages" for web services.
Web services uses UDDI for discovery and lookup services.
8/6/2019 Web Service Using JAX WS
36/59
WSDL
Web Service(J2EE, PL/SQL,
.NET,C/C++,
Legacy )
Web Service(J2EE, PL/SQL,
.NET,C/C++,
Legacy )
Web ServiceClient
(J2EE, .NET,
PL/SQL )
Web ServiceClient
(J2EE, .NET,
PL/SQL )
Points to
description
Describes
Service
Finds
Service
Invokes with
XML Messages
BasicWeb Services
SOAP
UDDI
Registry
Points toservice
8/6/2019 Web Service Using JAX WS
37/59
8/6/2019 Web Service Using JAX WS
38/59
8/6/2019 Web Service Using JAX WS
39/59
8/6/2019 Web Service Using JAX WS
40/59
8/6/2019 Web Service Using JAX WS