web services1 implementing a service-oriented architecture

21
Web services 1 Web services Implementing a service- oriented architecture

Upload: andrew-beville

Post on 31-Mar-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web services1 Implementing a service-oriented architecture

Web services 1

Web services

Implementing a service-oriented architecture

Page 2: Web services1 Implementing a service-oriented architecture

Technology until now

• Socket – connection (raw data wrap into other streams)

• HTTP – connection (get,put,post text)

• ‘Outdated’ – not tried– CORBA (general object oriented method call)– RMI (java object oriented method call)

Web services 2

Page 3: Web services1 Implementing a service-oriented architecture

Web services 3

SOA Service-Oriented Architecture

• Nodes in a network make resources available to other participants in the network as services

• Accessed in a standardized way• Loosely coupled services• Platform independent• Programming language independent

• Web services makes SOA happen!

Page 4: Web services1 Implementing a service-oriented architecture

Web services 4

SOA terms• Service

– Business function– Accepts requests, produces responses

• Provider (server)– Function which performs a service in response to a request from

a consumer• Consumer (client)

– Function which consumes the result of a service supplied by a provider

• Discovery– Ability to identify services– Using a repository / registry

• Binding– Relationship between provider and consumer is dynamic

• Established at runtime

Page 5: Web services1 Implementing a service-oriented architecture

Web services 5

Web servicesThe idea

• Technology that allows applications to communicate– Platform independent– Programming language independent– Send XML messages– Can use many transport protocols– Uses open standards

• Web services are– Developed by technical people– Aggregated into solving business problems by

business people

Page 6: Web services1 Implementing a service-oriented architecture

Web services 6

Web services standards

Open standards defined by – W3C http://www.w3.org – OASIS http://www.oasis-open.org

• Supported by any major company– Microsoft– Sun Microsystems– IBM– Oracle– and many others

Page 7: Web services1 Implementing a service-oriented architecture

Web services 7

Web services, technologies

• SOAP– Simple Object Access Protocol

• WSDL– Web Service Description Language

• UDDI– Universal Description, Discovery, and Integration

• XML– eXtensible Markup Language– Used by all web service technologies

Page 8: Web services1 Implementing a service-oriented architecture

Overview

Web services 8

Serviceregistry

Servicerequestor

Serviceprovider

Service

Find Publish

Bind (SOAP)(WSDL)

(UDDI)

Page 9: Web services1 Implementing a service-oriented architecture

Web services 9

XML• Language to describe data to be exchanged on the web

– And many other things– Programs exchange XML documents– XML documents are processed by programs

• Mark up language– XML tags structures information

• Element– <tag>…</tag>– An element may have many sub-elements

• Nested elements– An element has exactly 1 super-element

• Except the root element, which has 0 super-elements

Example XML document<persons> <person> <name>Anders</name> <city>Roskilde</city> </person> <person> <name>Peter</name> <city>Sorø</city> </person></persons>

Page 10: Web services1 Implementing a service-oriented architecture

Web services 10

Structure in XML documents• Well-formed

– All start-tags must have a matching end-tag• <person>…</

persons>

– Tags must be properly nested• <persons>•

<person>…</person>

• </persons>

– Only 1 outer tag• Called the root

element

• Valid– Well-formed– Conforms to an

XML schema• A set of “grammar

rules”• Specifies which

tags are allowed, etc.

Page 11: Web services1 Implementing a service-oriented architecture

Web services 11

SOAP

• XML is fine for data exchange, but it’s not enough– We need distinction between the header and the body of the

message• Like in HTTP

• A SOAP message in an XML document consisting of– Envelope (mandatory)– Headers (optional)– Body (mandatory)– Example

• http://java.sun.com/developer/technicalArticles/WebServices/soa2/WSProtocols.html

– Attachments (images and other binary content)

Page 12: Web services1 Implementing a service-oriented architecture

SOAP protocol

Web services 12

Page 13: Web services1 Implementing a service-oriented architecture

Web services 13

SOAPSimple Object Access Protocol

• SOAP messages can be transported using any transport protocol– HTTP– SMTP– Others– SOAP messages are tunneled through firewalls

• SOAP messages can be produced and consumed using any programming language– Sender and receiver can be written in different programming

language– Sender and receiver need not know what programming

language the other part was written in

Page 14: Web services1 Implementing a service-oriented architecture

Web services 14

WSDLWeb Services Description Language

• Clients use a WSDL file to learn how to call a web service

• WSDL file is an XML document describing the public interface to a web service– Message formats

• Operations– Methods which can be called on the web service– Parameters and return types to the methods

– Protocol bindings• Protocol used for transportation

– Examples• http://java.sun.com/developer/technicalArticles/WebServices/

soa2/WSProtocols.html

Page 15: Web services1 Implementing a service-oriented architecture

Web services 15

UDDIUniversal Description, Discovery, and Integration

• An UDDI registry is like a phone book (yellow pages)– Web service producers register

• Details of the business providing the service• Informal description of the functionality of the service• Location of the WSDL file• Information allowing users to register for information about updates to

the service– Web service consumers search the registry for useful services

• UDDI uses XML for registration• Several organizations run public UDDI registries

– IBM– Microsoft – Others

• Private UDDI registries– Most UDDI registries are found inside companies

Page 16: Web services1 Implementing a service-oriented architecture

Web services 16

Web service security

• Integrity– SOAP messages are not tampered with

• Confidentiality– SOAP message can only be seen by intended

recipients• Authentication

– Web service can only be called by authenticated clients

• Underlying technologies– Secure Socket Layer (SSL)– And many others

Page 17: Web services1 Implementing a service-oriented architecture

Web services 17

WS-BPEL Web Services Business Process Execution Language

• Business processes means calling more web services in a specific sequence.

• BPEL coordinates web services– Web services are components– BPEL defines a sequence (work flow) of calls

to web services

Page 18: Web services1 Implementing a service-oriented architecture

Web services 18

JAX-RPC / JAX-WS Java API for XML-based RPC

• RPC– Remote Procedure Call– Calling a method on a remote object

• JAX-RPC– Using web services to call remote methods from a Java

program• How it works

1. Java program invokes a method on a stub2. Stub invokes routines in the JAX-RPC runtime system (RS)3. RS converts the remote method invocation into a SOAP

message4. RS transmits the message as an HTTP request

• JAX-RPC is part of Java Enterprise Edition (J2EE)• JAX-WS is the new version of JAX-RPC

Page 19: Web services1 Implementing a service-oriented architecture

Web services 19

JAX-RPC data types• Primitive types

– Works well– As primitive types or wrapper classes

• Integer ~ int• Collections

– Arrays [ ] work– List, etc. work.

• Custom types (your own classes)– Must be XML serializable

• No-arg constructor• Get and set methods on all properties

• Exception(s)– Send as SOAP Faults (wrapped)– Can be quite hard to understand on the client side

Page 20: Web services1 Implementing a service-oriented architecture

Web services 20

Referencesand further reading

Web services in general• Ed Ort Service-Oriented Architecture and Web

Services: Concepts, Technologies, and Tools, Sun 2005

– http://java.sun.com/developer/technicalArticles/WebServices/soa2/WSProtocols.html

• Misc. references– http://en.wikipedia.org/wiki/SOAP_(protocol) – http://en.wikipedia.org/wiki/Webservices – http://www.w3.org/2002/ws/ – http://www.w3schools.com/webservices/

(ASP.NET)• Martin Kalin Java Web Services, O’Reilly

2009• Bill Burke RESTful Java with JAX-RS,

O’Reilly 2009• John Flanders RESTful .NET, O’Reilly 2008• Singh et al. Designing Web Services with the

J2EE 1.4 Platform, Addison Wesley 2004• Companies

– http://www-01.ibm.com/software/solutions/soa/– http://www.oracle.com/technologies/soa/index.ht

ml

– http://java.sun.com/webservices/

Page 21: Web services1 Implementing a service-oriented architecture

Web services 21

References, technologies• XML

– http://en.wikipedia.org/wiki/XML– http://www.w3schools.com/xml/– http://www.w3.org/XML/

• SOAP– http://en.wikipedia.org/wiki/SOAP

_(protocol)

– http://www.w3.org/2000/xp/Group

/

– Englander Java and SOAP, O’Reilly 2002

• WSDL– http://en.wikipedia.org/wiki/Web_

Services_Description_Language

– http://www.w3.org/2002/ws/desc/

• UDDI– http://en.wikipedia.org/wiki/UDDI – http://www.uddi.org/– http://uddi.microsoft.com/

• JAX-RPC / JAX-WS– http://en.wikipedia.org/wiki/JAX-R

PC

– http://en.wikipedia.org/wiki/JAX-WS

• Web service catalogs– http://www.remotemethods.com/ – http://www.webservicex.net/WS/