WS Unit 1
WS Unit 1
Restaurant example
A simple definition:
The Web Services model follows the publish, find, and bind
paradigm.
Web Service
Registry
1. publish 2. find
• How the service is implemented, and how a user of the service accesses
it, are limited only by the SOA infrastructure choices of the enterprise.
• Jini
• Java based
• Incorporates discovery, leasing, anonymous routing.
• Takes advantage of code mobility afforded by Java
• Web services
• Open standards based
• Uses XML as the data description format
• Usually runs on open transports such as http.
Distributed Computing Infrastructure
Distributed Computing
• Distributed computing studies the models, architectures, and
algorithms used for building and managing distributed systems.
• As general definition of the term distributed system, we use the
one proposed by Tanenbaum
• A distributed system is a collection of independent computers that
appears to its users as a single coherent system.
• A distributed system is one in which components located at networked
computers communicate and coordinate their action only by passing
messages.
• As specified in this definition, the components of a distributed
system communicate with some sort of message passing. This
is a term the encompasses several communication models.
Maya Nair 7/29/2021 23
Components of distributed System
Applications
Frameworks for
distributed programming
Middleware
IPC primitives for
control and data.
Operating System
Networking and
Parallel Hardware
Hardware
Maya Nair 7/29/2021
24
Examples of Distributed Systems
• Banking systems
• Communication - email
• Distributed information systems
• WWW
• Federated Databases
Three Tier
N Tier
server
Server/clie Server/clien
client
Maya Nair nt t server
7/29/2021 27
Peer-to-Peer architectural Style
peer
peer
peer
peer
peer
peer
peer
Maya Nair 7/29/2021 28
Communication Technologies for Distributed computing
7/29/2021 30
Maya Nair
Distributed object frameworks
Distributed object frameworks extend object-oriented programming systems by allowing
objects to be distributed across a heterogeneous network and provide facilities so that they
can coherently act as though they were in the same address space
1. The server process maintains a registry of active objects that are made available to other
processes. According to the specific implementation, active objects can be published using
interface definitions or class definitions.
2. The client process, by using a given addressing scheme, obtains a reference to the active
remote object. This reference is represented by a pointer to an instance that is of a shared
type of interface and class definition.
3. The client process invokes the methods on the active object by calling them through the
reference previously obtained. Parameters and return values are marshaled as happens in
the case of RPC.
Ex:
• Common Object Request Broker Architecture (CORBA):
• Distributed Component Object Model (DCOM/COM+)
• Remote Method Invocation(RMI)
• .NET Remoting
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle=http://www.w3.org/2001/12/soap-encoding”>
<soap:Body xmlns:m="http://www.stock.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>
SOAP Response
HTTP/1.1 200 OK
Content-Type: application/soap; charset=utf-8
Content-Length: 126
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-
envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-
encoding">
<soap:Body xmlns:m="http://www.stock.org/stock">
<m:GetStockPriceResponse>
<m:Price>34.5</m:Price>
</m:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>
Soap Structure (contd.)
⚫ One-way
❖ The service receives a message. The
operation therefore has a single input element.
The grammar for a one-way operation is:
❖ <wsdl:definitions .... > <wsdl:portType .... > *
<wsdl:operation name="nmtoken"> <wsdl:input
name="nmtoken"? message="qname"/>
</wsdl:operation> </wsdl:portType >
</wsdl:definitions>
WSDL Patterns of Operation
⚫ Request-response
❖ The service receives a message and sends a response. The
operation therefore has one input element, followed by one
output element. To encapsulate errors, an optional fault
element can also be specified. The grammar for a request-
response operation is:
❖ <wsdl:definitions .... > <wsdl:portType .... > *
• <wsdl:operation name="nmtoken"
parameterOrder="nmtokens">
• <wsdl:input name="nmtoken"? message="qname"/>
<wsdl:output name="nmtoken"? message="qname"/>
<wsdl:fault name="nmtoken" message="qname"/>*
</wsdl:operation>
• </wsdl:portType > </wsdl:definitions>
WSDL Patterns of Operation
⚫ Solicit-response
❖ The service sends a message and receives a response.
The operation therefore has one output element, followed
by one input element. To encapsulate errors, an optional
fault element can also be specified. The grammar for a
solicit-response operation is:
❖ <wsdl:definitions .... > <wsdl:portType .... > *
<wsdl:operation name="nmtoken"
parameterOrder="nmtokens"> <wsdl:output
name="nmtoken"? message="qname"/> <wsdl:input
name="nmtoken"? message="qname"/> <wsdl:fault
name="nmtoken" message="qname"/>*
</wsdl:operation>
• </wsdl:portType > </wsdl:definitions>
WSDL Patterns of Operation
⚫ Notification
❖ The service sends a message. The operation
therefore has a single output element. Following is
the grammar for a notification operation:
❖ <wsdl:definitions .... > <wsdl:portType .... > *
<wsdl:operation name="nmtoken">
<wsdl:output name="nmtoken"?
message="qname"/>
</wsdl:operation> </wsdl:portType >
</wsdl:definitions>
UDDI
( Universal Description, Discovery and Integration)
⚫ What is UDDI?
– Directory service where businesses can register and
search for Web services
⚫ Directory for storing information about web services
⚫ Directory of web service interfaces described by WSDL
– UDDI communicates via SOAP
– Ex. IBM® WebSphere® UDDI Registry, uddi.microsoft.com
Marketplaces, search
2. engines, and business
apps query the registry to
discover services at other
companies
Yellow pages
contains industrial categorization
Green pages
Technical information about the services that are exposed
by the businesses
<t Model>
<business Service> Name
(1..n) Description
URL pointers
<binding Template>
➢Business Entity is a top level information manager for the business unit
– serves as white and yellow pages
UDDI Benefits
⚫ Making it possible to discover the right
business from the millions currently online
⚫ Defining how to enable commerce once the
preferred business is discovered
⚫ Reaching new customers and increasing
access to current customers
⚫ Expanding offerings and extending market
reach
Types of UDDI nodes
• A SOAP-based web service could be implemented as a single Java class but, following
best practices, there should be an interface that declares the methods, which are the
web service operations, and an implementation, which defines the methods declared in
the interface.
• The interface is called the SEI: Service Endpoint Interface.
• The implementation is called the SIB: Service Implementation Bean. The SIB can be either a
POJO or a Stateless Session EJB (Enterprise Java Bean).
JAX-WS annotations
• Java API for XML-Based Web Services (JAX-WS) relies on the use of
annotations to specify metadata associated with Web service
implementations and to simplify the development of Web services.
Annotations describe how a server-side service implementation is
accessed as a Web service or how a client-side Java class accesses Web
services.
Specifying that the JWS File Implements a Web Service
(@WebService Annotation)
• Use the standard @WebService annotation to specify, at the class level, that the JWS file
implements a Web Service, as shown in the following code excerpt:
• @WebService(name="SimplePortType", serviceName="SimpleService",
targetNamespace="http://example.org")
• In the example, the name of the Web Service is SimplePortType, which will later map to
the wsdl:portType element in the WSDL file generated by the jwsc Ant task. The service
name is SimpleService, which will map to the wsdl:service element in the generated WSDL
file. The target namespace used in the generated WSDL is http://example.org.
• You can also specify the following additional attributes of the @WebService annotation:
• endpointInterface—Fully qualified name of an existing service endpoint interface file. This
annotation allows the separation of interface definition from the implementation. If you specify this
attribute, the jwsc Ant task does not generate the interface for you, but assumes you have created it
and it is in your CLASSPATH.
• portname—Name that is used in the wsdl:port.
• None of the attributes of the @WebService annotation is required.
Specifying That a JWS Method Be Exposed as a Public Operation
(@WebMethod and @OneWay Annotations)
• Use the standard @WebParam annotation to customize the mapping between operation input
parameters of the Web Service and elements of the generated WSDL file, as well as specify
the behavior of the parameter, as shown in the following code excerpt:
• public class SimpleImpl { @WebMethod()
@WebResult(name="IntegerOutput",
targetNamespace="http://example.org/docLiteralBare")
public int echoInt(
@WebParam(name="IntegerInput",
targetNamespace="http://example.org/docLiteralBare")
int input) {
System.out.println("echoInt '" + input + "' to you too!");
return input;
}
...
Customizing the Mapping Between the Operation Return Value and a
WSDL Element (@WebResult Annotation)
• Use the standard @WebResult annotation to customize the mapping between the
Web Service operation return value and the corresponding element of the generated
WSDL file, as shown in the following code excerpt:
• public class Simple { @WebMethod()
@WebResult(name="IntegerOutput",
targetNamespace="http://example.org/docLiteralBare")
public int echoInt(
@WebParam(name="IntegerInput",
targetNamespace="http://example.org/docLiteralBare")
int input) {
System.out.println("echoInt '" + input + "' to you too!");
return input;
}
...
Rules for methods on classes annotated with
@WebService
The following rules apply for methods on classes annotated with the @WebService
annotation.
• If the @WebService annotation of an implementation class references an SEI, the
implementation class must not have any @WebMethod annotations.
• All public methods for an SEI are considered exposed methods regardless of
whether the @WebMethod annotation is specified or not. It is incorrect to have an
@WebMethod annotation on an SEI that contains the exclude attribute.
• For an implementation class that does not reference an SEI, if the @WebMethod
annotation is specified with a value of exclude=true, that method is not exposed. If
the @WebMethod annotation is not specified, all public methods are exposed
including the inherited methods with the exception of methods inherited from
java.lang.Object.
The basic steps for creating a web service and client are as follows:
/**
* The @WebService property endpointInterface links the
* SIB (this class) to the SEI (ts.TimeServer).
* Note that the method implementations are not annotated
* as @WebMethods.
*/
@WebService(endpointInterface = "ts.TimeServer")
public class TimeServerImpl implements TimeServer {
public String getTimeAsString() { return new Date().toString(); }
public long getTimeAsElapsed() { return new Date().getTime(); }
}
Publish the Web Service
Once the SEI and SIB have been compiled,
Security Token
SOAP Envelope
SOAP Body
Signature
SOAP Body
Enables the scenario
SOAP
“WSS-module”
Secure
SOAPSOAP
…and this:
“WSS-module”
SOAP
Web Service
WS Security specification
• WS-Policy
This specification describes general security capabilities, constraints, and policies.
For example, a WS-Policy assertion could stipulate that a message requires security
tokens or that a particular encryption algorithm be used.
• WS-Trust
This specification deals primarily with how security tokens are to be issued,
renewed, and validated. In general, the specification covers brokered trust
relationships.
• WS-Privacy
This specification explains how services can state and enforce privacy policies. The
specification also covers how a service can determine whether a requester intends
to follow such policies.
• WS-SecureConversation
This specification covers, as the name indicates, secure web service
conversations across different sites and, therefore, across different security
contexts and trust domains. The specification focuses on how a security
context is created and how security keys are derived and exchanged.
• WS-Federation
This specification addresses the challenge of managing security identities
across different platforms and organizations. At the heart of the challenge
is how to maintain a single, authenticated identity (for example, Alice’s
security identity) in a heterogeneous security environment.
• WS-Authorization
This specification covers the management of authorization data such as
security tokens and underlying policies for granting access to secured
resources.
WS-Security is often associated with federated security in the broad sense,
which has the goal of cleanly separating web service logic from the high-
level security concerns, in particular authentication/authorization, that
challenge web service deployment. This separation of concerns is meant to
ease collaboration across computer systems and trust realms.