web services1 implementing a service-oriented architecture
TRANSCRIPT
Web services 1
Web services
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
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!
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
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
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
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
Overview
Web services 8
Serviceregistry
Servicerequestor
Serviceprovider
Service
Find Publish
Bind (SOAP)(WSDL)
(UDDI)
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>
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.
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)
SOAP protocol
Web services 12
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
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
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
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
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
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
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
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/
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/