1.01k likes | 1.24k Views
4. Service Oriented Architecture 4.1. An Introduction. Enterprise Service Bus (ESB). SOA = S ervice O riented A rchitecture. Web Services. SOA = Service Oriented Architecture
E N D
Enterprise Service Bus (ESB) SOA = Service Oriented Architecture Web Services • SOA = Service Oriented Architecture The services on the ESB are: a) thought to be integrated – “service oriented”;b) registered on a directory server; c) typically orchestrated.
SOA • Service Oriented Architecture • A system is made up of autonomous entities (sub-systems) which act independently of each other. All systems have interfaces which were thought explicitly for system integration. • Sub-systems have a course granularity (e.g. billing, warehouse, purchasing, etc.), typically being capable of executing independently of each other. These subsystems, and in particular their integration interfaces, are called services. • A possible way of implementing a SOA is using Web Services and related technologies. «An SOA is an orchestrated sequence of messaging, transformation, routing and processing events in which XML technologies expose the message content and the components that operate on the messages.»
System B System C System D System A Service Interface Service Interface Service Interface Service Interface Enterprise Service Bus SOA in a nutshell Process Orchestrator Service Directory A Service Oriented Architecture
Services != Distributed Objects • Different Deployment Model • Services are “hosted” instead of distributed based on their computational function • Encapsulation is made at the interface level (business driver) and not at implementation level • Interception and chaining of services is natural • Routing is performed based on content and context • High level of granularity • High autonomy • Integration Structure • Integration interfaces (services) where thought explicitly for that • Common business models among partners
Why use a SOA? • Future, Scalability and Evolution! • An organization is made up of many different systems. Sooner or later they will have to talk to each other. (typically, sooner than latter!) • If systems are not thought from the beginning for integration, the solutions found for doing so will be ad-hoc, without possibility of evolution, and with high development and maintenance costs • Using a Service Bus and a Service Oriented Architecture allows for future evolution, both by easily adding new services and, if necessary, replacing existing service implementations • A SOA allows to do so with minimal disruption of the business processes of an organization.
The importance of Open Standards • It’s absolutely important that a SOA is based on Open Standards • It allows the architecture to stay in place on the long-run • Allows external services to be easily integrated into the organization’s infrastructure • Allows for the substitution of existing systems by better ones (e.g. better technology, with a lower cost of ownership, or that are more adequate to the organization’s strategy) • Technologies like XML, HTTP, SOAP e 1st generation Web Services and 2nd generation WS play a vital role «It allows applications to bind to services that evolve and improve over time without requiring modification to the applications that consume them»
Moving into Services To From • Connections = cost • Function oriented • Build to last • Prolonged development • Connections = value • Process oriented • Build for change • Incrementally deployed • Application silos • Tightly coupled • Object oriented • Orchestrated solutions • Loosely coupled • Message oriented (c) Microsoft
Business Process View Coarse Grained Web Service Operations Finer Grained Internal Service Operations Fine Grained Object and database calls BusinessComponent BusinessComponent ConsumerApplication Business Process
SOA based on Web Services • First Generation Web Services • HTTP, XML, XSD, WSDL, SOAP Web Services • UDDI • Second Generation Web Services • Allow for a Service Oriented Architecture • WS-* Specifications • WS-Routing • WS-Referral • WS-Inspection • WS-Security • WS-Attachments • WS-Coordination • WS-Transaction • WS-SecureConversation • WS-SecurityPolicy • WS-Policy • WS-PolicyAttachment • WS-PolicyAssertions • WS-Addressing • WS-ReliableMessaging
Autonomous systems, viewed as services S4 S5 S6 They are capable of sending and receiving messages S2 S7 Orchestration Logic S1 S8 UI1 User Interfaces UI4 UI2 UI3 What does it look like? S3
?$#%$# ?$#%$# ?$#%$# Web Services? Warehouse Java/J2EE JavaRMI Portal Billing CORBA COBOL DCOM VB/ASP
Web Services! • The first step to have interoperable systems is to based them on open standards, de facto supported by industry • All systems must be able to talk a common language Warehouse Java/J2EE WS SOAP XML SOAP XML Portal Billing WS COBOL WS VB/ASP SOAP XML
Web Services • What’s a web service? «A web service consists in an application identified by a URI which can be accessed over the internet using open standards like SOAP/XML»
Evolution of the Web XML HTML Technology TCP/IP Presentation Programmability Connectivity FTP, E-mail, Gopher Innovation Web Pages 1 Web Services Browse the Web 2 Program the Web 3
Web Services • XML • Representing messages using a platform-independent universal format. • SOAP = Simple Object Access Protocol • Allows to transport XML messages between systems in a simple an middleware-independent way. • The underlying protocol is normally HTTP. But, others can be used (SMTP, FTP, ...) • HTTP Port 80 is good [Well, sort of... ] • WSDL = Web Services Definition Language • Describes web services (i.e. the service contract) • UDDI = Universal Description, Discovery, and Integration • Directory service which allows to register and discover web services
Web Service Model Service Description Service Registry FIND 2 PUBLICATION WSDL, UDDI 3 WSDL, UDDI Service Requester 4 Service Provider Service Service Description BIND SOAP 1 • Web service is installed • Web service is registered • Client(s) lookup web service • Web service is instantiated (n times), possibly by many clients
HTTP/FTP/SMTP UDDI WSDL SOAP XML Web Services Stack?
XML based protocol for exchange of information Encoding rules for datatype instances Convention for representing RPC invocations Designed for loosely-coupled distributed computing No remote references Used with XML Schema Transport independent SOAP with Attachments allow arbitrary data to be packaged. SOAP1.1 Message Structure SOAP Envelope Header Entries [Header Element] Body Element [Fault Element] SOAP
Node types SOAP Receiver • Three node types: sender nodes, intermediate nodes, receiver nodes • Destination nodes (i.e. intermediate or final nodes) are identified on the Header of the messages (env:role) • Typical values of env:role are “next” (processed by the intermediate and final nodes) and “ultimateReceiver” (only processed by the final node) • Messages (payload) exchanged between SOAP nodes can be: • RPC-based (i.e. method invocation) • Document-based (i.e. you send/receive an XML document) • It’s also possible to exchange messages containing BLOBs of binary data (SOAP Messages with Attachments) SOAP Intermediary SOAP Sender Intermediary Service Service Provider Service Requester
Web Services Types • Document/Literal (Wrapped) • The payload of the SOAP message is an XML document that can be validated against XML schema. The document itself is represented as method parameters (Wrapped approach). • Document/Literal (Bare) • Bare is an implementation detail from the Java domain. Neither in the abstract contract (i.e. wsdl+schema) nor at the SOAP message level is a bare endpoint recognizable. • A bare endpoint or client uses a Java bean that represents the entire document payload. • RPC/Literal (Wrapped) • With RPC there is a wrapper element that names the endpoint operation. Child elements of the RPC parent are the individual parameters. It’s “calling methods” using XML, not passing documents. • Note: there is no complex type in XML schema that could validate the entire SOAP message payload. • RPC/Encoded • Shouldn’t be used! “SOAP encodeding style is defined by the infamous chapter 5 of the SOAP-1.1 specification. It has inherent interoperability issues that cannot be fixed. The Basic Profile-1.0 prohibits this encoding style”
Web Services Types • JBoss extends available web services types to include a very useful mechanism: direct XML Elements. • “You may come to the point where RPC/literal or Document/literal is not what you are looking for. This may be the case for instance, when you want to do the XML processing yourself instead of deferring it to the SOAP stack. JBossWS offers the possiblity to setup message style endpoints that do exchange raw XML documents mapped to DOM elements or SOAPElements”(JBoss Web Services Guide) • This means that you can pass directly an XML tree created in memory as parameter. • Called “Message Style Endpoints” public interface Shop extends Remote { public Element getInvoice(Element client) throws RemoteException; } http://labs.jboss.com/jbossws/user-guide/en/html/1.0.4/en/html/getting-started.html
SOAP Messages <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getProductDetailsxmlns="http://warehouse.example.com/ws"> <productID>827635</productID> </getProductDetails> </soap:Body> </soap:Envelope> Request <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getProductDetailsResponse xmlns="http://warehouse.example.com/ws"> <getProductDetailsResult> <productName>Toptimate 3-Piece Set</productName> <productID>827635</productID> <description>3-Piece luggage set.</description> <price>96.50</price> <inStock>true</inStock> </getProductDetailsResult> </getProductDetailsResponse> </soap:Body> </soap:Envelope> Response
HTTP Request HTTP Body XML Syntax SOAP Envelope SOAP Body SOAP Body Block Textual Integer Sender Receiver 0x0b66 What’s the problem with all this? • Computationally heavy and data heavy! • 1 byte of information many bytes of context • 1 byte of information many CPU cycles of processing
WSDL = Web Services Description Language • Used for describing SERVICE INTERFACES • Datatypes used by the web service • What methods are available for invocation • What are the input and output parameters • Which are the SERVICE IMPLEMENTATIONS available • Which are the endpoints (bindings) • Which are the supported transport protocols • WSDL is the Interface Definition Language of Web Services
A WSDL document describes What the service can do Where it resides How to invoke it WSDL are like IDL but lot more flexible and extensible Defines binding for SOAP1.1, HTTP GET/POST and MIME WSDL descriptions can be made available from an UDDI registry What does a WSDL document looks like? WSDL1.1 Document Structure WSDL Document [Types] {Messages} {Port Types} {Bindings} {Services}
Format of a WSDL document XML-Schema of all data types Parameters of a service Listing of available services Maps services to protocols: SOAP, HTTP, etc. The service’s URL <definitions> <types> <schema></schema> </types> <message> <part></part> </message> <portType> <operation></operation> </portType> <binding> <operation></operation> </binding> <service> <port></port> </service> </definitions>
WSDL example <?xmlversion="1.0" encoding="utf-8"?> <definitionsname=“BookStore" ... > ... </definitions> <types><schema> ... </schema></types> <messagename="ISBN_Number"> <partname="isbn" type="xs:string"/> </message> <messagename="BookInfo"> <partname="title" type="xs:string"/> <partname="author" type="xs:string"/> </message> <portTypename="Catalog"> <operationname="GetBookByISBN"> <input name="isbn_number"message="ISBN_Number"/> <output name=“result"message="BookInfo"/> </operation> </portType> ... Data types Messages used by the service Abstract service definition
WSDL example (2) <bindingname="BookByISBN_SOAP_Binding" type="Catalog"> <soap:bindingstyle="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation> <soap:operation soapAction="/GetBookByISBN"/> <input><soap:bodyuse="literal"/></input> <output><soap:bodyuse="literal"/></output> </operation> </binding> <servicename="ACME_Book_Service"> <documentation>ACME BOOKS CATALOG</documentation> <portname="BookByISBN_Port" binding="BookByISBN_SOAP_Binding"> <soap:addresslocation="http://acmebooks.com/webservices"/> </port> </service> </definitions> Maps the service into the HTTP protocol Binds the service mapping into an address endpoint
Luckly... • In many cases you don’t need to know the details behind WSDL. (But some times you do!) • There are tools to automatically generate all the necessary classes for the target programming language you are using
3. 1. SW companies, standards bodies, and programmers populate the registry with descriptions of different types of services Marketplaces, search engines, and business apps query the registry to discover services at other companies 2. 4. BusinessRegistrations Service Type Registrations Businesses populate the registry with descriptions of the services they support Business uses this data to facilitate easier integration with each other over the Web UDDI • A directory service for web services UDDI Business Registry
UDDI (2) • The initial objective was that different organizations and companies would register their businesses on a central directory. Other companies looking for functionality would look them up. • Didn’t happen! • Organizations and companies don’t work that way! • Even so, UDDI is extremely useful when implementing a SOA. It can serve as a centralized repository for all services available in an organization! • Easy lookup and orchestration
Problems Interoperability!!! ?
Web Services Interoperability Organization • Supervises the process of having compatible WS stacks among players • Strategy: Profiles and Tests Interoperability • With so many specifications (XML, XSD, SOAP, WSDL, UDDI), it’s really hard to setup a system that is able to talk with another system on a different platform • Different versions, different implementation, different interpretations of standards…
WS-I Basic Profile 1.1 • A WS stack implementation is compliant with WS-I Basic Profile 1.1 if it correctly supports: • SOAP 1.1 • HTTP/1.1 • HTTP State Management Mechanism (RFC2965) • XML 1.0 (2nd Edition) • XML Schema (Part I+II) • WSDL 1.1 • UDDI 2.0 (2.04 API, 2.03 Data Structure, 2 XML Schema) • HTTP over TLS (RFC2818) • TLS 1.0 • SSL 3.0 • X.509 (RFC2459) • ... with some extensions and amendments... • WS-I Basic Profile 1.2 was issued on March 2007
Seen in SD We’ll see it as an example... Recommended for the 2nd assignment (but not compulsory) APIs for Web Services • For developing web services you can use a number of platforms, application servers, and APIs • Sun J2EE Application Server • AXIS + Tomcat • BEA WebLogic • Microsoft.NET + IIS • JBoss WS
A simple web service Algoritmos.asmx <%@ WebService Language="C#" Class="Algoritmos" %> using System;using System.Web.Services; publicclassAlgoritmos : WebService{[WebMethod]publicint Soma(int a, int b) {return a + b; }}
Says that the web service is written in C# Says which class corresponds to the web service Example of a web service <%@ WebService Language="C#" Class="Algoritmos" %> using System;using System.Web.Services; publicclassAlgoritmos : WebService{[WebMethod]publicint Soma(int a, int b) {return a + b; }} Algoritmos.asmx
How to deploy it? • Using MS Internet Information Server (IIS)... • You just have to create a new folder in the IIS web document directory and copy the file there. c:\Inetput\wwwroot\Matematica\Algoritmos.asmx http://localhost/Matematica/Algoritmos.asmx
Calling... Which results in... Manually testing the web service
tempuri.org? • “tempuri.org” is a temporary namespace. To change it, define it at the web service level. <%@ WebService Language="C#" Class="Algoritmos" %> using System;using System.Web.Services; [WebService(Namespace="http://www.dei.uc.pt/Algoritmos")]publicclassAlgoritmos : WebService{[WebMethod]publicint Soma(int a, int b) {return a + b; }}
How can I use the service? • Obviously, the idea is to use the web service from an application, not through a web browser. • The wsdl.exe application generates the necessary files for including the service into your code.