Top Banner
TPG Confidential Technology Practices Group Java Competency Framewo "Incubate, Nurture and Deploy Technology Experts Innovate, Build and Deliver Technology Solutions”
92
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Level 2.3 CBT Course on SOA-Final-Old

TPG Confidential

Technology Practices Group Java Competency Framework

"Incubate, Nurture and Deploy Technology Experts Innovate, Build and Deliver Technology Solutions”

Page 2: Level 2.3 CBT Course on SOA-Final-Old

IntroductionIntroduction

2TPG Confidential

Business Unit BFSI

Group Technology Practices Group

Practice Java Practice

Sub-Practices Java CoE technologies

Initiative Competency Framework

Competency Level 2.3 [Level 4]Experience Level 2-3 YearsPre-Requisite Application Server fundamentals, XML,Java

programming

Version 1.0

Author Java TPG

Total number of slides 92

Duration of learning 4 Hours including coding and exercise

Page 3: Level 2.3 CBT Course on SOA-Final-Old

AgendaAgenda

•SOA Introduction & Architecture

•Web Services Introduction & Architecture

•Web Services Type

•Introduction to SOAP

•Introduction to WSDL

•Introduction to UDDI

•Introduction to Java WS

Page 4: Level 2.3 CBT Course on SOA-Final-Old

Principles ofPrinciples ofService OrientationService Orientation

Page 5: Level 2.3 CBT Course on SOA-Final-Old

SOA - DefinitionSOA - Definition

The policies, practices and frameworks

that enable application functionality to be provided and

consumed as sets of services

published at a granularity relevant to the service consumer,

which are abstracted away from the implementation

using a single, standards based form of interface.

Page 6: Level 2.3 CBT Course on SOA-Final-Old

SOA Defined..SOA Defined..

… a service?

A repeatable business task – e.g., check customer credit;

open new account

… service orientation?

A way of integrating your business as linked

servicesand the outcomes that

they bring

… service oriented architecture (SOA)?

An IT architectural style that supports service orientation

… a composite application?

A set of related & integrated services that

support a business process built on an SOA

More

Page 7: Level 2.3 CBT Course on SOA-Final-Old

Principles of Service Orientation - ArchitecturePrinciples of Service Orientation - Architecture

First Order Concept: Services are an independent, first order concept Loosely Coupled:

– Abstracted: Services are independent of a specific software implementation– Platform Independent: Services are delivered in a platform independent technology

Designed and built for Agility: Services should incorporate agility into their design, not just use loosely coupled technology.

Articulating: Services should be designed as points of flexibility across functional boundaries and technology layers

Meaningful: Services should be delivered at a level of granularity and abstraction that is meaningful to the service consumer.

Contract-Based: Services should use a “design by contract” approach to ensure that all participants are aware of their precise obligations when providing or consuming the Service

Standards-Based: Services should comply with appropriate standards for both technology and business domains

Discoverable: Services should be published in a manner by which they can be discovered and consumed without intervention of the provider

Page 8: Level 2.3 CBT Course on SOA-Final-Old

Principles of Service Orientation - ProcessPrinciples of Service Orientation - Process

Federation: The SOA is a collaboration of independent components, that provide services according to contractual obligations

Traceability: Service should be visible throughout life cycle, from business perspective to deployed software service

Alignment of Business and IT: The SOP should ensure clear alignment and mapping between the business service, and the software service

Evolutionary: SOP should be an agile process that facilitates continuous change

Managed: Services should be managed as an asset throughout the service life cycle

Application Neutral: The concept of SOP and SOA is applicable to all classes of interoperability

Page 9: Level 2.3 CBT Course on SOA-Final-Old

What are Services? (Technical definition)What are Services? (Technical definition)

Contracted interfaces to software functionality and data that communicate via messages

Technically, a Service interface

Page 10: Level 2.3 CBT Course on SOA-Final-Old

Characteristics of ServicesCharacteristics of Services

Services are loosely coupled – making a change to a Service provider does not mandate changing any Service consumers.

Business processes are composed of Services, and are in turn exposed as Services. Services are policy-driven – business users can change how a Service behaves. Systems are inherently integrated by virtue of composable Services – not through

layers of middleware. Services leverage legacy systems – SOA does not mandate replacement of runtime

infrastructure, but enable migration when needed. In SOA, metadata control how the system behaves instead of code – business logic

trumps application logic. In SOA, it’s the contracted interface that matters, not the underlying runtime

environment.

Page 11: Level 2.3 CBT Course on SOA-Final-Old

Service Oriented Architecture (SOA)Service Oriented Architecture (SOA)

Page 12: Level 2.3 CBT Course on SOA-Final-Old

Architectural ScopeArchitectural Scope Some architecture is always

required Focus shifts to the interfaces as

scope increases

– How do the parts connect Role of the architect depends on

scope

– Am I designing the building? Only care about my

building External interfaces are a

given – can’t change– Or the city plan?

What should the interfaces be?

Need wide agreement Don’t design every single

building

Page 13: Level 2.3 CBT Course on SOA-Final-Old

Service Layer How do you connect

sales to customers?

.NETLinux

J2EE Unix

OS/390

MQ

DB2

Technology Layer Hardware, Network How do you connect J2EE

to .NET?

Architecture LayersArchitecture Layers

Finance

PeopleSoft

SAP

SiebelDir

OutlookApplication Layer Applications, Components,

Software How do you connect SAP to

Siebel?

Business Process Layer Cross Functional End-to-

end Sales Order Process

CustomerEmployee

SalesProduct

Page 14: Level 2.3 CBT Course on SOA-Final-Old

Principle – Services are a First Order ConceptPrinciple – Services are a First Order Concept

Services are an independent, first order concept A Service provides a view of a functional capability that is consistent

across many use cases. The Service view is common to business requirements, design, deployment, assets and configured resources. A software Service might be related to a functional interface, but should not be taken as a synonym for interface. This applies to both the Business Service and Software Service. This enables:

– Improved alignment of business to software Service in comparison to mapping to functional interfaces

– A more abstract view to be taken of the service

– Complex mappings of software service to functional interface (e.g. many to many)

– Service treatment as an asset and resource

Page 15: Level 2.3 CBT Course on SOA-Final-Old

Types of ServiceTypes of Service

Business Service

Software Service

Software Service

Business Process

Business Product

Supports

Implements

Executes

Business

Application

Deployment

Page 16: Level 2.3 CBT Course on SOA-Final-Old

Types of Service - ExampleTypes of Service - Example

Pay as you drive

Register Journey

http://paydins.com/regjourney

Vehicle Insurance

Sales

Vehicle Insurance

Supports

Implements

Executes

Business

Application

Deployment

Page 17: Level 2.3 CBT Course on SOA-Final-Old

Service ManagementService Management Service Providers

– Who is allowed in?– Am I meeting Service Level Agreements?– Who will get the bill?– How do we route requests to different implementations

Service Consumers– Who used the service?– Are Service Level Agreements being met?– Which budget holder will pay?– How do we route requests to different Service Providers

The problem is the same and the solution should be symmetrical

Service Implementation

Service Implementation

Service Implementation

WebService

WebService

WebService

ConsumingApplication

ConsumingApplication

ConsumingApplication

Services Manager

Services Manager

PROVIDER

CONSUMER

Page 18: Level 2.3 CBT Course on SOA-Final-Old

What are Web Services?What are Web Services?

“A Web service is a software system identified by a URI whose public interfaces and bindings are defined and described using XML. Its definition can be discovered by other software systems. These systemsmay then interact with the Web service in a manner prescribed by its definition, using XML-based messages conveyed by Internet protocols.”

- World Wide Web Consortium (W3C)

Page 19: Level 2.3 CBT Course on SOA-Final-Old

ServiceIntermediary

Service ProviderService Consumer

What are Web Services?What are Web Services?

ServiceRequest

Service

Standards based protocols to describeMessage format

Services and Endpoints

Addressing and Routing

Secure, Reliable Transactions

Business Process OrchestrationPublication and Discovery

ProcurementSystem

J2EE

SalesSystem

.NET

Page 20: Level 2.3 CBT Course on SOA-Final-Old

Foundation for Web Services

Ubiquitous Communications: InternetUbiquitous Communications: Internet

Universal Data Format:Universal Data Format: XMLXML

Service Interactions:Service Interactions: SOAPSOAP

Formal Service Descriptions:Formal Service Descriptions: WSDLWSDL

Publish, Find, Use Services:Publish, Find, Use Services: UDDIUDDI

Page 21: Level 2.3 CBT Course on SOA-Final-Old

SummarySummary

SOA is more than Web Services

– Service is the important concept, not Web Service SOA is not just a wiring diagram Services AND Components are required to fully deliver IT and Business

Agility

– Component Based Service Engineering (CBSE) Service Orientation

– A set of principles and policies

– An approach Consider Service across the whole lifecycle, not just deployment Follow the Principles of Service Orientation Comprehend Agility at all stages

– Analysis, Design, Build, Deployment

Page 22: Level 2.3 CBT Course on SOA-Final-Old

Introduction to SOAPIntroduction to SOAP

Page 23: Level 2.3 CBT Course on SOA-Final-Old

Introduction to SOAPIntroduction to SOAP

•SOAP stands for Simple Object Access Protocol •SOAP is a communication protocol •SOAP is for communication between applications •SOAP is a format for sending messages •SOAP is designed to communicate via Internet •SOAP is platform independent •SOAP is language independent •SOAP is based on XML •SOAP is simple and extensible •SOAP allows you to get around firewalls •SOAP will be developed as a W3C standard

Why SOAP?•Today's applications communicate using Remote Procedure Calls (RPC) between objects like DCOM and CORBA, but HTTP was not designed for this. RPC represents a compatibility and security problem; firewalls and proxy servers will normally block this kind of traffic.•A better way to communicate between applications is over HTTP, because HTTP is supported by all Internet browsers and servers. SOAP was created to accomplish this.

•SOAP provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.

Page 24: Level 2.3 CBT Course on SOA-Final-Old

XML Messaging Using SOAPXML Messaging Using SOAP

1. A SOAP client formats a message in XML including a SOAP “envelope” element describing the message

2. The client sends the message to a SOAP server in the body of an HTTP request3. The server determines whether the message is valid and supported4. The server formats its response in XML and sends it to the client in the body of

an HTTP response

Page 25: Level 2.3 CBT Course on SOA-Final-Old

What is a soap messageWhat is a soap message

A SOAP message is an ordinary XML document containing the following elements:

•A required Envelope element that identifies the XML document as a SOAP message •An optional Header element that contains header information •A required Body element that contains call and response information •An optional Fault element that provides information about errors that occurred while processing the message •All the elements above are declared in the default namespace for the SOAP envelope:

SOAP Message SOAP Message AnatomyAnatomy

<SOAP-ENV:Envelope xmlns:SOAP-ENV="SoapEnvelopeURI"SOAP-ENV:encodingStyle="SoapEncodingURI">

<SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body>

<m:GetLastTradePrice xmlns:m="ServiceURI"><tickerSymbol>SUNW</

tickerSymbol></m:GetLastTradePrice>

</SOAP-ENV:Body></SOAP-ENV:Envelope>

Message Message RepresentationRepresentation

Page 26: Level 2.3 CBT Course on SOA-Final-Old

Syntax RulesSyntax Rules

Here are some important syntax rules:

A SOAP message MUST be encoded using XML A SOAP message MUST use the SOAP Envelope namespace A SOAP message MUST use the SOAP Encoding namespace A SOAP message must NOT contain a DTD reference A SOAP message must NOT contain XML Processing Instructions

Page 27: Level 2.3 CBT Course on SOA-Final-Old

SOAP Message ComponentsSOAP Message Components

Envelope (required)

– Contains Header and Body

– Defines namespaces (optional)

– Declares encoding rules (optional) Header (optional)

– Contains metadata entries about message a la HTTP headers

– Specifies which entries must be understood and by which target “actor” in chain of recipients

Page 28: Level 2.3 CBT Course on SOA-Final-Old

SOAP Message ComponentsSOAP Message Components

Body (required)

– Contains application-specific message

– May be encoded variously Fault element (optional)

– Contained in Body

– Describes error class (version mismatch, headers not understood, client error, server error)

– Extensible, hierarchical fault codes, e.g. Server.Availability.NotAvailable

Page 29: Level 2.3 CBT Course on SOA-Final-Old

Example SOAP MessageExample SOAP Message <SOAP-ENV:Envelope>

<SOAP-ENV:Header> <lib:PatronID SOAP-ENV:mustUnderstand=“1”> 007 </lib:PatronID> </SOAP-ENV:Header>  <SOAP-ENV:Body>    <lib:Checkout>     <callNo>435.33</callNo> </lib:Checkout>  </SOAP-ENV:Body></SOAP-ENV:Envelope>

body

header

Page 30: Level 2.3 CBT Course on SOA-Final-Old

Why Not Just Put Everything in the Header?Why Not Just Put Everything in the Header?

The Header is optional SOAP specializations for RPC require using the body to pass

parameters and results (we’ll get to that later) Otherwise, no reason The SOAP spec notes that a body entry is semantically-equivalent to

an optional header entry (with “mustUnderstand” = 0)

Page 31: Level 2.3 CBT Course on SOA-Final-Old

Encoding Data in SOAPEncoding Data in SOAP

SOAP permits arbitrary “encoding styles” and defines a default encoding style

Based on XML-Schema Supports data types

– All built-in XML-Schema types (e.g. string, float, integer, date, IDREF)– Derived types: enumerations, arrays, structs, generic compound types

Page 32: Level 2.3 CBT Course on SOA-Final-Old

Encoding Data in SOAP: accessorsEncoding Data in SOAP: accessors

Typed elements are called “accessors” Accessor types are specified in externally-referenced XML-Schema

definitions Or with the xsi:type attribute, e.g.

<a:uid xsi:type=“xsd:integer”> 4737</a:uid>

Page 33: Level 2.3 CBT Course on SOA-Final-Old

Encoding Data in SOAP: structsEncoding Data in SOAP: structs

Structs are simple compound types consisting of uniquely-named accessors, e.g.

<naut:Ship> <name>Titanic</name> <length>882’</length> <height>104’</height> <weight>46,328 tons</weight></naut:Ship>

Page 34: Level 2.3 CBT Course on SOA-Final-Old

Encoding Data in SOAP: arraysEncoding Data in SOAP: arrays

Arrays can be built of any type, e.g.

<SOAP-ENC:Array SOAP-ENC:arrayType="phNo[]"> <phNo>217-435-4927</phNo> <phNo>217-957-4937</phNo></SOAP-ENC:Array>

Array values can be of any subtype of the array’s declared type

Page 35: Level 2.3 CBT Course on SOA-Final-Old

Encoding Data in SOAP (cont.)Encoding Data in SOAP (cont.)

Values can be used in multiple places using references <e:Book>   <title>My Life</title>   <author href="#Person-1"/> </e:Book> <e:Person id="Person-1">   <name>Henry Ford</name> </e:Person>

Including ref’s to external resources

Page 36: Level 2.3 CBT Course on SOA-Final-Old

Using SOAP for RPCUsing SOAP for RPC

Methods are invoked by making a SOAP request to a URI representing the target object

Method calls are represented in the Body by a struct named after the method

Struct members represent in/out parameters to the method The method result is encoded similarly and returned in a SOAP

response Errors are signaled with the Fault entry

Page 37: Level 2.3 CBT Course on SOA-Final-Old

RPC Example: Digital LibraryRPC Example: Digital Library

Supports card catalog search and checkout Target objects / methods

– Catalog / search

– Circulation / checkout, return Security

– Authentication: patron ID

– Fault: unrecognized user

Page 38: Level 2.3 CBT Course on SOA-Final-Old

RPC Example: Digital LibraryRPC Example: Digital Library

Catalog

– Represented by a URI, e.g.http://www.lib.org/catalog/

– Supports one method: Search Find items which match a particular query Result: list of entries containing information about items Fault condition: malformed query

Page 39: Level 2.3 CBT Course on SOA-Final-Old

RPC Example: Catalog SearchRPC Example: Catalog Search

POST /catalog/ HTTP/1.1Content-type: text/xml

<SOAP-ENV:Envelope> <SOAP-ENV:Body> <lib:Search> <author>Kafka</author> </lib:Search> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 40: Level 2.3 CBT Course on SOA-Final-Old

RPC Example: Catalog Search ResponseRPC Example: Catalog Search Response

HTTP/1.1 200 OKContent-type: text/xml

<SOAP-ENV:Envelope> <SOAP-ENV:Body> <lib:SearchResponse> <lib:Item> <callNo>473.57</callNo> </lib:Item> …

Page 41: Level 2.3 CBT Course on SOA-Final-Old

Introduction to WSDLIntroduction to WSDL

Page 42: Level 2.3 CBT Course on SOA-Final-Old

What is WSDL?What is WSDL?

Web Service Description Language WSDL is a document written in XML The document describes a Web service Specifies the location of the service and the methods the service exposes

Why WSDL

Without WSDL, calling syntax must be determined from documentation that must be provided, or from examining wire messages

With WSDL, the generation of proxies for Web services is automated in a truly language- and platform-independent way

Where does this fit in

SOAP is the envelope containing the message WSDL describes the service UDDI is a listing of web services described by WSDL

Page 43: Level 2.3 CBT Course on SOA-Final-Old

Document StructureDocument Structure Written in XML Two types of sections

– Abstract and Concrete Abstract sections define SOAP messages in a platform- and language-independent manner Site-specific matters such as serialization are relegated to the Concrete sections

Abstract sections– Types: Machine- and language-independent type definitions. – Messages: Contains function parameters (inputs are separate from outputs) or document

descriptions. – PortTypes: Refers to message definitions in Messages section that describe function

signatures (operation name, input parameters, output parameters). Concrete Descriptions

– Bindings: Specifies binding(s) of each operation in the PortTypes section. – Services: Specifies port address(es) of each binding.

Operations

– An operation is similar to a function in a high level programming language– A message exchange is also referred to as an operation – Operations are the focal point of interacting with the service

Page 44: Level 2.3 CBT Course on SOA-Final-Old

Big PictureBig Picture

Page 45: Level 2.3 CBT Course on SOA-Final-Old

An ExampleAn Example

<?xml version="1.0" encoding="UTF-8" ?> This first line declares the document as an XML document. Not required, but helps the XML parser determine whether to parse

the file or signal an error

Page 46: Level 2.3 CBT Course on SOA-Final-Old

Types SectionTypes Section

The type element defines the data types that are used by the web service.

<xsd:complexType name="PERSON"> <xsd:sequence>

<xsd:element name="firstName“ type="xsd:string"/> <xsd:element name="lastName" type="xsd:string"/>

<xsd:element name="ageInYears" type="xsd:int"/> </xsd:sequence> </xsd:complexType>

Page 47: Level 2.3 CBT Course on SOA-Final-Old

Messages SectionMessages Section

A message element defines parameters The name of an output message element ends in "Response" by

convention

<message name="Simple.foo"> <part name="arg" type="xsd:int"/> </message>

<message name="Simple.fooResponse"> <part name="result" type="xsd:int"/> </message>

Page 48: Level 2.3 CBT Course on SOA-Final-Old

PortTypes SectionPortTypes Section

Defines a web service, the operations that can be performed, and the messages that are involved.

<portType name="SimplePortType"> <operation name="foo" parameterOrder="arg" > <input message="wsdlns:Simple.foo"/> <outputmessage="wsdlns:Simple.fooResponse"/> </operation> </portType>

Page 49: Level 2.3 CBT Course on SOA-Final-Old

Bindings SectionBindings Section

The binding element defines the message format and protocol details for each port.

<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetLastTradePrice"> <soap:operation soapAction="http://example.com/GetLastTradePrice"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding>

Page 50: Level 2.3 CBT Course on SOA-Final-Old

The Port ElementThe Port Element

Each <port> element associates a location with a <binding> in a one-to-one fashion

<port name="fooSamplePort" binding="fooSampleBinding"> <soap:address location="http://carlos:8080/fooService/foo.asp"/> </port>

Page 51: Level 2.3 CBT Course on SOA-Final-Old

Services SectionServices Section

A collection of related endpoints, where an endpoint is defined as a combination of a binding and an address

<service name="FOOSAMPLEService"> <port name="SimplePort“ binding="wsdlns:SimpleBinding"><soap:address location="http://carlos:8080/FooSample/ FooSample.asp"/> </port> </service>

Page 52: Level 2.3 CBT Course on SOA-Final-Old

NamespacesNamespaces

The purpose of namespaces is to avoid naming conflicts. Imagine two complimentary web services, named A and B, each with

an element named “foo”. Each instance of foo can be referenced as A:foo and B:foo Example: "xmlns:xsd" defines a shorthand (xsd) for the namespace See http://www.w3.org/2001/XMLSchema.

Page 53: Level 2.3 CBT Course on SOA-Final-Old

WSDL: ExampleWSDL: Example

Sample WSDL file Describes port type, binding,

input, output, Service name and URL

<?xml version="1.0" encoding="UTF-8"?>

<definitions name ="DayOfWeek" targetNamespace="http://www.roguewave.com/soapworx/examples/DayOfWeek.wsdl" xmlns:tns="http://www.roguewave.com/soapworx/examples/DayOfWeek.wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/">

<message name="DayOfWeekInput"> <part name="date" type="xsd:date"/> </message> <message name="DayOfWeekResponse"> <part name="dayOfWeek" type="xsd:string"/> </message>

<portType name="DayOfWeekPortType"> <operation name="GetDayOfWeek"> <input message="tns:DayOfWeekInput"/> <output message="tns:DayOfWeekResponse"/> </operation> </portType>

<binding name="DayOfWeekBinding" type="tns:DayOfWeekPortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetDayOfWeek"> <soap:operation soapAction="getdayofweek"/> <input> <soap:body use="encoded" namespace="http://www.roguewave.com/soapworx/examples" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input>

Source: Rogue Wave

<output> <soap:body use="encoded" namespace="http://www.roguewave.com/soapworx/examples" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding>

<service name="DayOfWeekService" > <documentation> Returns the day-of-week name for a given date </documentation> <port name="DayOfWeekPort" binding="tns:DayOfWeekBinding"> <soap:address location="http://localhost:8090/dayofweek/DayOfWeek"/> </port> </service>

</definitions>

Page 54: Level 2.3 CBT Course on SOA-Final-Old

Introduction to UDDIIntroduction to UDDI

Page 55: Level 2.3 CBT Course on SOA-Final-Old

Lucida Sans UnicodeLucida Sans Unicode

UDDI is a open, cross-industry effort driven by major platform and software providers, as well as marketplace operators and e-business leaders within the OASIS standard consortium

It defines a standard method for publishing and discovering the network-based software components of a service-oriented architecture

UDDI creates a standard interoperable platform that enables companies and applications to quickly, easily and dynamically find and use Web services over the Internet

Page 56: Level 2.3 CBT Course on SOA-Final-Old

UDDI and Web ServicesUDDI and Web Services

The UDDI protocol is another XML-based building block of the Web services stack along with SOAP (standard for invoking remote operations) and WSDL (standard for specifying what these operations look like)

UDDI supplies an infrastructure for systematically addressing needs such as discovery, manageability and security of Web services beyond what is the simple organization of their interactions

By addressing integration, coordination and flexibility issues of service-oriented systems, UDDI plays an important role within the service-oriented approach to enterprise software design

Page 57: Level 2.3 CBT Course on SOA-Final-Old

Accessing Web Services with UDDIAccessing Web Services with UDDI

In some cases it may be that the information that are necessary to access Web services are known and thus directly stored within the applications that use them

Nonetheless it is possible that the definitions and descriptions of such services (WSDL) are published to be discovered on ad hoc on-line registries

UDDI defines how these registry should be designed and how to use them to describe, publish and discover services on a network

Rather than forcing applications to include information about an external service's application programming interfaces, UDDI registry provide this binding information dynamically, at run-time

UDDI guarantees flexibility with respect both to the dynamic run-time changes that occur during the life-cycle of web services and to the evolution of web application requirements

Page 58: Level 2.3 CBT Course on SOA-Final-Old

UDDI’s Role in WS Software DevelopmentUDDI’s Role in WS Software Development

By adopting UDDI, it turns out that convenience for developers, requirements of enterprise architects, and underlying business policies are not in opposition

UDDI facilitates Web services software development by providing systematic, interoperable, standards-based:– Management of the development process of web services– Approach for documenting and publishing web services– Organizations and managing of web services across multiple

systems and development teams– Documenting interface specification through teams and through

time and for external applications above all in case of change UDDI help drive better code reuse and developer productivity (can

help developers - across groups - find a shared service and use that service within their own applications)

Page 59: Level 2.3 CBT Course on SOA-Final-Old

UDDI’s Role in SO InfrastructureUDDI’s Role in SO Infrastructure

UDDI facilitates Service-Oriented Infrastructure:

– Insulates critical applications from changes or failures in backend services:

Provides a formal layer of indirection (almost a firewall) necessary for service-oriented application development and management, useful for accommodating changes in the life cycle of specific components (updates, policy considerations, service termination)

– Helps an organization share information about services in a controlled way that reflects its own business rules and policies:

Client authentication and publish/subscribe for peer registries satisfy operational governance needs as control of the publication and distribution of information about deployed services according to business policies

Solutions are not hard-coded but takes advantage of run-time binding

Page 60: Level 2.3 CBT Course on SOA-Final-Old

UDDI from the Businesses’ Point of View (1/2)UDDI from the Businesses’ Point of View (1/2)

The UDDI Project enables businesses to:– Discover each other– Define how they interact over the internet and share information in a

global registry architecture– Enact policy-based distribution and management of enterprise web

services The UDDI project is not industry specific

– Any industry, of any size, worldwide, offering products and services can benefit from this open initiative because the specifications comprehensively addresses problems that limit the growth and synergies of B2B commerce and Web services.

Before the UDDI project, there was no industry-wide approach for business to reach their customers and partners with information about their products and Web services, nor there was a method of how to integrate into each other's systems and processes.

UDDI is the building block that enables businesses to quickly, easily and dynamically find and transact with one another via their preferred applications.

Page 61: Level 2.3 CBT Course on SOA-Final-Old

UDDI from the Businesses’ Point of View (2/2)UDDI from the Businesses’ Point of View (2/2)

Problems solved:– Makes it possible for organizations to quickly discover the right business

from millions currently on line– Defines how to enable commerce to be conducted once the preferred

business is discovered Immediate benefits for businesses:

– Reaching new customers– Expanding offerings– Extending market reach– Increasing access to current customers– Solving customer-driven need to remove barriers to allow for rapid

participation in the global Internet economy– Describing their services and business processes programmatically in a

single, open and secure environment– Using a set of protocols that enables businesses to invoke services over

the internet to provide additional value to their preferred customers

Page 62: Level 2.3 CBT Course on SOA-Final-Old

UDDI FeaturesUDDI Features

UDDI is similar to the concepts of DNS and yellow pages In short, UDDI provides an approach to:

– Locate a service

– Invoke a service

– Manage metadata about a service UDDI specifies:

– Protocols for accessing a registry for Web services

– Methods for controlling access to the registry

– Mechanism for distributing or delegating records to other registries

Page 63: Level 2.3 CBT Course on SOA-Final-Old

UDDI SpecificationsUDDI Specifications

UDDI defines:

– SOAP APIs that applications use to query and to publish information to a UDDI registry

– XML Schema schemata of the registry data model and the SOAP messages format

– WSDL definitions of the SOAP APIs

– UDDI registry definitions (technical model - tModels) of various identifier and category systems that may be used to identify and categorize UDDI registrations

The UDDI Specifications Technical Committee also develops Technical Notes and Best Practice documents that aid users in deploying and using UDDI registries effectively

Page 64: Level 2.3 CBT Course on SOA-Final-Old

UDDI Registry ServiceUDDI Registry Service

The UDDI specifications define a registry service for Web services and for other electronic and non-electronic services

A UDDI registry service is a Web service that support the description and discovery of service providers, service implementations, and service metadata

UDDI is a meta service for locating web services by enabling robust queries against rich metadata.

Service providers can use UDDI to advertise the services they offer Service consumer can use UDDI to discover services that suites their

requirements and to obtain the service metadata needed to consume those services.

Page 65: Level 2.3 CBT Course on SOA-Final-Old

UDDI RegistryUDDI Registry

Functional purpose: representation of data and metadata about Web services Either for use on a public network or within on organizational internal

infrastructure Offers standards-based mechanism to classify, catalog and manage Web

services so that they can be discovered and consumed by other applications Implements generalized strategy of indirection amongst services based

applications Offers benefits to IT managers both at design and run-time, including code

reuse and improving infrastructure management

Page 66: Level 2.3 CBT Course on SOA-Final-Old

UDDI Registry TypesUDDI Registry Types UDDI allows operational registries to be maintained for different purposes in

different contexts A business may deploy one or more:

– Private registries: Isolated from the public network, firewalled Restricted access No shared data

– Public registries: Unrestricted open and public access Data is shared with other registries

– Affiliated registries Controlled environment Access limited to authorized clients Data shared in a controlled manner

Private registry supports intranet applications, while a public registry support extranet applications

Affiliated registries supports all other infrastructural topologies e.g., involving delegation, distribution, replication, subscription, that reflects the realities and the relationship of the underlying business processes

Page 67: Level 2.3 CBT Course on SOA-Final-Old

UDDI Registry Data ModelUDDI Registry Data Model

The core information model of UDDI registries is made of several data structures:– businessEntity (info about the organization that published the service)– businessService (description of a service business function)– bindingTemplate (service’s technical details, including a reference to the

API)– tModel (attributes or metadata about the service such as taxonomies,

transports, digital signatures)– publisherAssertions (relationship among entities in the registry, v2.0)– Subscription (standing request to track changes to a list of entities)

Each data structure within a given registry is assigned a unique UDDI key UDDI allows users to specify different taxonomies for providing semantic

structure to the information about Web services contained in a registry

Page 68: Level 2.3 CBT Course on SOA-Final-Old

UDDI ServersUDDI Servers

UDDI specifies hierarchical relationship between a single instance of a UDDI implementation and others to which it is related

UDDI Servers can be:

– Nodes: supports a minimum set of functionalities of the specification (they are member of exactly one registry)

– Registry: composed of one or more nodes; supports the complete set of functionalities of the specification

– Affiliated registry: registry that implements a policy-based sharing of information together with other affiliated registry

Registry Affiliation is the main achievement of UDDI V3.0

– Recognition that UDDI is to support the design and operations of myriads software applications within and among business organizations (not only private/public registries)

Page 69: Level 2.3 CBT Course on SOA-Final-Old

UDDI APIUDDI API

Features that supports core data management:

– Publishing information about a service to a registry

– Searching a UDDI registry for information about a service Features that supports registry interaction:

– Replicating and transferring custody of data about a service

– Registration key generation and management

– Registration subscription API set

– Security and authorization These are divided in Node API Sets (for UDDI Servers) and Client

API Sets (for UDDI Clients)

Page 70: Level 2.3 CBT Course on SOA-Final-Old

UDDI SolutionsUDDI Solutions

Several categories of product and components– UDDI Registry Server, UDDI-enabled IDEs and development

tools, Java and .NET client toolkits and browsers, UDDI-integrated Web services platforms

Supplied by multiple vendors, consortia and also available as open source– Apache.org, BEA, IBM, Microsoft, Oracle, SAP, Sun, Systinet,

UDDI4J.org jUDDI is an open sourceJava based implementation of a UDDI v2

registry and a toolkit UDDI4J is a Java class library that provides an API to interact with a

UDDI registry Java Web Service Developer Pack by Sun Web Application Server by SAP Webshpere UDDI Registry by IBM

Page 71: Level 2.3 CBT Course on SOA-Final-Old

Introduction to Java Web ServicesIntroduction to Java Web Services

Page 72: Level 2.3 CBT Course on SOA-Final-Old

Lucida Sans UnicodeLucida Sans Unicode

Part of Java EE. New in Java SE 6. API stack for web services. Replaces JAX-RPC. New API’s: JAX-WS, SAAJ, Web Service metadata New packages: javax.xml.ws, javax.xml.soap,javax.jws

Page 73: Level 2.3 CBT Course on SOA-Final-Old

Software required.Software required.

Java WSDP 1.6 Bundle

• This can be downloaded from : http://java.sun.com/webservices/download/webservicespack.html

Application Server • Sun Java System Application Server Platform Edition 8.1 2005Q2 UR2

may be used as the build and runtime environment. The Application Server and J2SE SDK are contained in the J2EE 1.4 SDK. you can download the Application Server from: http://java.sun.com/j2ee/1.4/download.html#sdk

Page 74: Level 2.3 CBT Course on SOA-Final-Old

What is JAX-WSWhat is JAX-WS

•JAX-WS stands for Java API for XML Web Services. •JAX-WS is a technology for building web services and clients that communicate using XML. •JAX-WS allows developers to write message-oriented as well as RPC-oriented web services.•In JAX-WS, a remote procedure call is represented by an XML-based protocol such as SOAP.The SOAP specification defines the envelope structure, encodingrules, and conventions for representing remote procedure calls and responses. These calls and responses are transmitted as SOAP messages (XML files) over HTTP.

Page 75: Level 2.3 CBT Course on SOA-Final-Old

Web Services Platform Architecture (WSPA)Web Services Platform Architecture (WSPA)

Invocation

– Proxies Represent Web Services in Java

– Interface to Messaging System (HTTP)

– QoS (Handlers) Marshalling (Impedance Matcher)

– Java/XML Binding Deployment

– Implement Web Service Endpoints (SOAP, REST) with Java

WSPA Identifies Three Components of JWS

Page 76: Level 2.3 CBT Course on SOA-Final-Old

InvocationInvocation

Invocation Subsystem (Client Side)

Java Method Invocation

SOAP Message Exchange

(Specified by WSDL)

Java Method Invocation

return

param

param

param

SE

I : J

ava

Pro

xy

Request : SOAP

Response : SOAP

Invocation Subsystem (Server Side)

Target : Java Object

Request : SOAP

Response : SOAP

return

param

param

param

SE

I : J

ava

Pro

xy

Page 77: Level 2.3 CBT Course on SOA-Final-Old

Java Proxies Represent Web ServicesJava Proxies Represent Web Services

Web Services Container

SOAP Endpoint

WSDL Interface

Java Virtual Machine

Web Service Proxy

Java Interface

<definitions ... targetNamespace="http://soabook.com" xmlns:soa="http://soabook.com" xmlns:wrapper="http://soabook.com/wrapper" ...> <types> <schema elementFormDefault="qualified" targetNamespace="http://soabook.com/wrapper" ...> <element name="customerPurchase"> <complexType> <sequence> <element ref="imported:customer"/> <element ref="imported:po"/> </sequence> </complexType> </element> ... </schema> ... </types> <message name="onCustomerPurchase"> <part element="wrapper:customerPurchase" name="purchase"/> </message> ... <portType name="CustomerPurchase"> <operation name="processCustomerPurchase"> <input message="soa:onCustomerPurchase" … /> ... </operation> </portType> ...</definitions>

package com.soabook;

import com.soabook.sales.Customer;import com.soabook.purchasing.PurchaseOrder;

public interface PurchaseTransactions {

public void newPurchase (Customer cust, PurchaseOrder po); ...}

SOAPMessage

Page 78: Level 2.3 CBT Course on SOA-Final-Old

DeploymentDeployment

Web Services Platform

Container (e.g., J5EE, Servlets, Axis)

+someMethod()

Java Target

Source Artifacts (e.g., EJB wrapper)

SOAP Handlers

-url

Endpoint Listener

Container Deployment Descriptors

WSDL/Java Mapping

BindingContext

Web Services Directory (e.g., UDDI)

+someOperation()

WSDL

WSDL Deployment

Page 79: Level 2.3 CBT Course on SOA-Final-Old

How to implement JAX-WSHow to implement JAX-WS

The starting point for developing a JAX-WS web service is a Java class annotated with the javax.jws.WebService annotation. The WebService annotation defines the class as a web service endpoint.A service endpoint interface (SEI) is a Java interface that declares the methods that a client can invoke on the service. An SEI is not required when building a JAX-WS endpoint. The web service implementation class implicitly defines a SEI.

Page 80: Level 2.3 CBT Course on SOA-Final-Old

Steps in creating the web service and clientSteps in creating the web service and client

These are the basic steps for creating the web service and client:

• Code the implementation class.• Compile the implementation class.• Deploy the WAR file. The tie classes (which are used to communicate

with clients) are generated by the Application Server during deployment.• Code the client class.• Use wsimport to generate and compile the stub files.• Compile the client class.• Run the client.

Page 81: Level 2.3 CBT Course on SOA-Final-Old

Requirements of a JAX-WS Endpoint Requirements of a JAX-WS Endpoint

JAX-WS endpoints must follow these requirements:

• The implementing class must be annotated with either the javax.jws.WebService or javax.jws.WebServiceProvider annotation.

• The implementing class may explicitly reference an SEI through the endpointInterface element of the @WebService annotation, but is not required to do so. If no endpointInterface is not specified in @WebService, an SEI is implicityly defined for the implementing class.

• The business methods of the implementing class must be public, and must not be declared static or final.

• Business methods that are exposed to web service clients must be annotated with javax.jws.WebMethod.

• Business methods that are exposed to web service clients must have JAX-B-compatible parameters and return types. See Default Data Type Bindings.

Page 82: Level 2.3 CBT Course on SOA-Final-Old

Requirements of a JAX-WS Endpoint Requirements of a JAX-WS Endpoint

• The implementing class must not be declared final and must not be abstract.

• The implementing class must have a default public constructor.• The implementing class must not define the finalize method.• The implementing class may use the javax.annotation.PostConstruct or

javax.annotation.PreDestroy annotations on its methods for lifecycle event callbacks.

• The @PostConstruct method is called by the container before the implementing class begins responding to web service clients.

• The @PreDestroy method is called by the container before the endpoint is removed from operation.

Page 83: Level 2.3 CBT Course on SOA-Final-Old

Writing a Service Endpoint Implementation Writing a Service Endpoint Implementation Class Class

package helloservice.endpoint;

import javax.jws.WebService;

@WebService()public class Hello { private String message = new String("Hello, ");

public void Hello() {}

@WebMethod() public String sayHello(String name) { return message + name + "."; }}

In this example, the implementation class, Hello, is annotated as a web service endpoint using the @WebService annotation. Hello declares a single method named sayHello, annotated with the @WebMethod annotation. @WebMethod exposes the annotated method to web service clients. sayHello returns a greeting to the client, using the name passed to sayHello to compose the greeting. The implementation class also must define a default, public, no-argument constructor

Page 84: Level 2.3 CBT Course on SOA-Final-Old

Building the Service Building the Service

To build HelloService, in a terminal window go to the <INSTALL>//examples/jaxws/helloservice/ directory and type the following:

The build task command executes these subtasks:

compile-service

The compile-service Task

Thisasant task compiles Hello.java, writing the class files to the build subdirectory. It then calls the wsgen tool to generate JAX-WS portable artifacts used by the web service. The equivalent command-line command is as follows:

wsgen -d build -s build -classpath build helloservice.endpoint.Hello The -d flag specifies the output location of generated class files. The -s flag specifies the

output location of generated source files. The -classpath flag specifies the location of the input files, in this case the endpoint implmentation class, helloservice.endpoint.Hello.

Page 85: Level 2.3 CBT Course on SOA-Final-Old

Packaging and Deploying the Service Packaging and Deploying the Service

You package and deploy the service using asant.

Upon deployment, the Application Server and the JAX-WS runtime generate any additional artifacts required for web service invocation, including the WSDL file.

Page 86: Level 2.3 CBT Course on SOA-Final-Old

Generate Stub CodeGenerate Stub Code

Packaging and Deploying the Service with asant

To package and deploy the helloservice example, follow these steps:

In a terminal window, go to <INSTALL>/javaeetutorial5/examples/jaxws/helloservice/.

Run asant create-war. Make sure the Application Server is started. Set your admin username and password in

<INSTALL>/javaeetutorial5/examples/common/build.properties. Run asant deploy. You can view the WSDL file of the deployed service by requesting the URL

http://localhost:8080/helloservice/hello?wsdl in a web browser. Now you are ready to create a client that accesses this service.

Undeploying the Service

you can undeploy the service by typing this command:

– asant undeploy

Page 87: Level 2.3 CBT Course on SOA-Final-Old

Testing the Service Without a Client Testing the Service Without a Client

The Application Server Admin Console allows you to test the methods of a web service endpoint. To test the sayHello method of HelloService, do the following:

Open the Admin Console by opening the following URL in a web browser: http://localhost:4848/

Enter the admin username and password to log in to the Admin Console. Click Web Services in the left pane of the Admin Console. Click Hello. Click Test. Under Methods, enter a name as the parameter to the sayHello method. Click the sayHello button. This will take you to the sayHello Method invocation page.

Under Method returned, you'll see the response from the endpoint.

Page 88: Level 2.3 CBT Course on SOA-Final-Old

A Simple JAX-WS Client A Simple JAX-WS Client

Coding the Client

When invoking the remote methods on the stub, the client performs these steps:

Uses the javax.xml.ws.WebServiceRef annotation to declare a reference to a web service. WebServiceRef uses the wsdlLocation element to specify the URI of the deployed service's WSDL file.

@WebServiceRef(wsdlLocation="http://localhost:8080/

helloservice/hello?wsdl")

static HelloService service;

Retrieves a proxy to the service, also known as a port, by invoking getHelloPort on the service.

Hello port = service.getHelloPort();

The port implements the SEI defined by the service.

Invokes the port's sayHello method, passing to the service a name.

String response = port.sayHello(name);

Page 89: Level 2.3 CBT Course on SOA-Final-Old

A simple WS client - ExampleA simple WS client - Example

package simpleclient;

import javax.xml.ws.WebServiceRef;import helloservice.endpoint.HelloService;import helloservice.endpoint.Hello;

public class HelloClient { @WebServiceRef(wsdlLocation="http://localhost:8080/ helloservice/hello?wsdl") static HelloService service;

public static void main(String[] args) { try { HelloClient client = new HelloClient(); client.doTest(args); } catch(Exception e) { e.printStackTrace(); } }

Page 90: Level 2.3 CBT Course on SOA-Final-Old

A simple WS client – Example (contd…)A simple WS client – Example (contd…) public void doTest(String[] args) { try { System.out.println("Retrieving the port from the following service: " + service); Hello port = service.getHelloPort(); System.out.println("Invoking the sayHello operation on the port.");

String name; if (args.length > 0) { name = args[0]; } else { name = "No Name"; }

String response = port.sayHello(name); System.out.println(response); } catch(Exception e) { e.printStackTrace(); } }}

Page 91: Level 2.3 CBT Course on SOA-Final-Old

A simple WS client – Example (contd…)A simple WS client – Example (contd…)

Building and Running the Client To build the client, you must first have deployed HelloServiceApp, as

described in "Packaging and Deploying the Service with asant." Then navigate to <JAVA_EE_HOME>/examples/jaxws/simpleclient/ and do the following:

– asant build

The run the client, do the following:

– asant run

Page 92: Level 2.3 CBT Course on SOA-Final-Old

Thank You