Docstoc

Web Services

Document Sample
Web Services Powered By Docstoc
					Web Services Technology

   COMP3150/7700 E-technology
Architectures, Tools and Applications
       (Semester 1, 2010/11)
• Some software functional block
   • Location, platform, code are irrelevant
• “Loosely coupled software components that encapsulate
  discrete functionality and that are accessible over standard
  Internet protocols.”—The Stencil Group
• “Web Services are a new breed of web application. They are
  self-contained, self-describing, modular applications that can be
  published, located, and invoked across the Web.”– IBM
• Web services are a form of distributed information system
                                              – Gustavo Alonso
                               Web services: concepts, architectures and applications




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)     2
                                                  Outline
• Client-Server to 3-Tier
• Middleware Technology
• Web services




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   3
                                                  Outline
• Client-Server to 3-Tier 
• Middleware Technology
• Web Services




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   4
                   Different Layers of an
                    Information System

                                                       Client


                                       Presentation Layer




                                                                                      Information
                                                                                         System
                                 Application Logic Layer


                                Res. Management Layer


COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                 5
                   Different Layers of an
                    Information System
• Conceptual Layers of an IS
       – Presentation Layer
          • For interacting with external entities (clients) for receiving
            requests & sending responses.
       – Application logic Layer
          • For system/process integration, business rule/logic
                 execution, …
               • References for business rules:
                   – http://www.businessrulesgroup.org/
       – Resource Management Layer
          • Data sources from databases or other information                                  Client
            systems, specialized computing services, …
                                                                                        Presentation Layer




                                                                                                                Information
                                                                                                                   System
                                                                                      Application Logic Layer



                                                                                      Res. Management Layer


COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                      6
                            From 1-tier to 3-tier
         1-tier                                              2-tier                              3-tier

                                                                                  Client                         Client
              UI                                                   UI                               UI


  Presentation Layer                                 Presentation Layer                      Presentation Layer


                                                                                  Server   Application Logic Layer
Application Logic Layer                          Application Logic Layer


Res. Management Layer                            Res. Management Layer                     Res. Management Layer




                                                 Middleware
    COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                      7
                 Application Framework
                                                                                       A
                                                                                       P
                                                               User Interface          P
                                                                                       L
                                                                                       I
                                                        Presentation Interface         C
  Userware                                                                             A
                                                                                       T
                                                           Task Management             I
                                                                                       O
                                                                                       N

Middleware                                                Control Integration


                                                            Data Repository
Enterpriseware
                                                            System Service


 Hardware                               Computer and Communication Facility

 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)       8
        Integration: 2-tier Approach
                                             (data-oriented)
              Rice A
                            combined catalog
              Rice B
              Rice B

              Drink C                                           UI
              Drink C
              Food D                                  Presentation
              Food D                                     Layer 1

              Food E               e.g., html or xml
 …
                                              Application Logic Layer


All logics are embedded                       Res. Management Layer
in your web programs
(e.g., *.asp, *.php, …)                                                                e.g., html or xml




 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                       9
           Integration: 3-tier Approach
                 Rice A
                                                 (data-oriented)
                 Rice B
                                                            Client
                 Rice B

                 Drink C
                                                 Presentation Layer
                 Drink C
     ...
                                  e.g., html or xml

                                             Application Logic Layer
                                Eg., integration rules &
e.g., The rule can be:          exception handling rules
If a source is not              (declarative)
responding, show                                         html or xml
“service not available” e.g., ODBC/Vendor_Specific_Protocol
and send a notification
                               Res. Management Layer
e-mail to Manager A
and ….                         Eg., database management
                               system (Oracle, DB2)

    COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   10
        Integration: 2-tier Approach
                                 (computation-oriented)


                                                                UI


                                                      Presentation
                                                         Layer 1
                                                                                       e.g., student essays
  e.g., analysis results    e.g., html or xml                                          (*.doc)
  in html/xml            Application Logic Layer


Logics for analysis are                       Res. Management Layer
embedded in the web
programs.
                                          Problem: The server is overloaded when
                                          the number of students increases.
 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                 11
            Integration: 3-tier Approach
                                      (computation-oriented)
                                                                UI


                                                  Presentation Layer
                                                                                           e.g., student essays
                                                        e.g., html or xml                  (*.doc)
                                              Application Logic Layer
                                               Eg., integration via message
                                               queues
Products that support
Java Message Service:
Apache ActiveMQ,                                                        e.g., JMS/Vendor-Specific-Protocol
Oracle AQ, IBM MQ,
etc.                                          Res. Management Layer
                                              Eg., database management
                                              system (Oracle, DB2)

     COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                     12
                                                  Outline
• Client-Server to 3-Tier
• Middleware Technology
• Web Services




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   13
    Middleware Technologies 101
          RPC -> Workflow

                                                                                      Web Process Design




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                 14
         Middleware Technologies:
             RPC -> Workflow
• Middleware – to handle the execution complexity for distributed
  applications
• Remote Procedure Call (RPC)
       – a process in a computer invokes a process in another
       – synchronous (wait until the response is ready)
• Going beyond simple RPC …
       – Transactional
               • with commit and rollback handling (error handling)
       – Message-oriented (e.g., Oracle AQ)
               • asynchronous, enabled by message queue
       – Message-brokering (e.g., Oracle Message Broker)
               • from O(nxn) to O(n) communication
               • support logic-dependent routing
       – Workflow Management System (e.g., Oracle Workflow)
               • process flow status control
               • Workflow --The automation of a business process, in whole or part,
                 during which documents, information or tasks are passed from one
                 participant (resource or human or machine) to another for action,
                 according to a set of procedural rules.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   15
             Globalization of Processes

         EAI                                              B2B                             E-Services




Workflows                                    Distributed                              Web Processes
                                             Workflows

  Enterprise                             Inter-Enterprise                             Global
                                    Processes driving the Networked Economy
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                    16
                                                  Outline
• Client-Server to 3-Tier
• Middleware Technology 101
• Web Services 




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   17
• Software as Services?

• Examples?



COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   18
  Service-Oriented Architecture
             (SOA)
• 3 fundamental operations:
       – publish
       – find
       – bind




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   19
 Web Services (1) – What is …
• Web Services
  – Software systems designed to support interoperable
    machine-to-machine interaction over a network.(W3C)
  – Messages in-between are XML-based
  – Internet based Remote Procedure Call (RPC)
      • Request/Response (so, synchronous essentially)
• Web Service Description Language (WSDL)
  – A XML-based markup language for specifying interfaces
    for consuming services over the network.



 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   20
 Web Services (2) – What is …
• UDDI
   – Universal Description, Discovery and Integration
   – A platform-independent XML-based registry for
     businesses worldwide to list themselves on the Internet.
• SOAP
   – Simply Object Access Protocol
   – A protocol for exchanging XML-based messages over
     computer networks by HTTP/HTTPS.




 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   21
           How can UDDI be Used
industry published an UDDI standard for flight
  rate checking and reservation;
airlines register their services into an UDDI
  directory.
Travel agencies search the UDDI directory to
  find the airline's reservation interface. The
  travel agency can communicate with the
  service immediately because it uses a well-
  defined reservation interface.
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   22
        Who is Supporting UDDI?
UDDI is supported by all major platform and
 software providers, like Dell, Fujitsu, HP,
 Hitachi, IBM, Intel, Microsoft, Oracle, SAP,
 and Sun.

Over 220 companies are members of the
 UDDI community.


 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   23
  Service-Oriented Architecture
             (SOA)
• 3 fundamental operations:
                                                                                        1
       – publish                                                                            Implement a web service
                                                                                            Define its WSDL

       – find
       – bind
 2                                                                           3 1. Look up service broker for web services
     Store the meta data of web services,                                        2. Develop a client program that can
     including where to locate the WSDL                                          communicate with the web service (based
     descriptions and support search.                                            on the WSDL description) and then
                                                                                 consume the web service.




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                                   24
                    Web Services Roles
• Service provider
      – Implements the services
      – Makes the services available on the web
• Service requestor
      – Consumes the web services
• Service registry
      – Logically centralized registry provides a central place
        where allows developers to publish new services or
        search (or discover) existing ones




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   25
  Web Services Procedures (1)
                                                        Service
                                                        Registry                         Register

                                                         UDDI
   WS Search &
 Discovery


    Service                                              SOAP Request                        Service
   Requester                                                                                  Provider
                                                        SOAP Response

                                      Retrieve WSDL Documents



COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                      26
   Web Services Procedures (2)
1. Web services providers register in UDDI Registry.
2. Web service consumers discover the desired
   web services in UDDI server.
3. Consumers retrieve the WSDL documents from
   desired web service providers.
4. Consumers send SOAP request messages to
   service providers.
5. Providers receive the requests, process them
   request, and return SOAP responses.


 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   27
          Web Services Description
            Language (WSDL)
4 critical pieces of information
• <portType>: describes a web service, the operations
   performed by the web service (the most important).
• <message>: defines the data elements of an
   operation.
• <type>: defines the data type used by the web
   service.
• <blinding>: defines the message format and protocol
   details for each port.




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   28
                WSDL Support 4 Basic
                  Operation Types




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   29
                             Binding to SOAP




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   30
                              Binding Element
The binding element has two
  attributes – name, type
• Name: defines the name of the
  binding (you can use any name you
  want).
• Type: points to the port for the
  binding, in this case the
  "glossaryTerms" port.


COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   31
                                 SOAP: Binding

 The soap:binding element has two
  attributes - style, transport
• Style: could be "rpc" or "document".
• Transport defines the SOAP
  protocol to use. In this case we use
  HTTP.


COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   32
                                            Operation
The operation element defines each
  operation that the port exposes.
--For each operation the corresponding
  SOAP action has to be defined. You
  must also specify how the input and
  output are encoded. In this case we use
  "literal".



COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   33
                                                                        Visit this following link for more detailed specification
                                                                                             http://www.w3.org/TR/wsdl#_wsdl


                   HelloServices.wsdl (1)
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="HelloService"
 targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl"
                                                                                                    Definition
 xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">


 <message name="SayHelloRequest">
   <part name="firstName" type="xsd:string"/>
 </message>
                                                                                                    Message
 <message name="SayHelloResponse">
   <part name="greeting" type="xsd:string"/>
 </message>




  COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                                  34
previous
slides                         HelloServices.wsdl (2)
      <portType name="Hello_PortType">
       <operation name="sayHello">
           <input message="tns:SayHelloRequest"/>
           <output message="tns:SayHelloResponse"/>
       </operation>                                                                                    PortType
     </portType>


     <binding name="Hello_Binding" type="tns:Hello_PortType">
                                                                                       matched operations
       <soap:binding style="rpc"
           transport="http://schemas.xmlsoap.org/soap/http"/>
                                                                                            “rpc” - simple data types
       <operation name="sayHello">
                                                                                            “document” – xml documents/data
           <soap:operation soapAction="sayHello"/>
           <input>
            <soap:body


                                                                                                         Binding
              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
              namespace="urn:examples:helloservice"
              use="encoded"/>
                                                                                            “encoded” – with data types based
           </input>
                                                                                            on encodingStyle
           <output>
                                                                                            “literal” – no encoding
            <soap:body
              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
              namespace="urn:examples:helloservice"
              use="encoded"/>
           </output>
       </operation>
     </binding>
      COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                               35
                       HelloServices.wsdl (3)
previous
slides


    <service name="Hello_Service">
        <documentation>WSDL File for HelloService</documentation>
        <port binding="tns:Hello_Binding" name="Hello_Port">
                                                                                            Service
           <soap:address
             location="http://localhost:8080/soap/servlet/rpcrouter"/>
        </port>
      </service>
    </definitions>




      COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)             36
                                What is SOAP?
•    SOAP stands for Simple Object Access Protocol
•    SOAP is XML-based
•    SOAP is a protocol for accessing a Web Service
•    SOAP is for communication between applications
•    SOAP is a format for sending messages
•    SOAP is via Internet (HTTP)
•    SOAP is platform independent
•    SOAP is language independent
•    SOAP will be developed as a W3C standard




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   37
                  SOAP Building Blocks
• 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



COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   38
                                     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



COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   39
                               SOAP Message




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   40
           Skeleton SOAP Message




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   41
                            Envelope Element
• The xmlns:soap namespace
• The encodingStyle attribute
--soap:encodingStyle="URI"
--<soap:Envelope
  xmlns:soap="http://www.w3.org/2001/12
  /soap-envelope"
  soap:encodingStyle="http://www.w3.org
  /2001/12/soap-encoding">


COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   42
                                Header Element
• Actor
 ---A SOAP message may travel from a sender to a
    receiver by passing different endpoints along the
    message path. The SOAP actor attribute is to
    address the Header element to a particular endpoint
• mustUnderstand=“0/1”
 ---It is to indicate whether a header entry is mandatory
    or optional for the recipient to process.
• encodingStyle




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   43
                             Header Element
• <?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:Header>
       <m:Trans xmlns:m="http://www.w3schools.com/transaction/"
       soap:mustUnderstand="1">234
      soap:actor="http://www.w3schools.com/appml/
       </m:Trans>
     </soap:Header>
     ...
     ...
     </soap:Envelope>




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   44
                                   Body Element




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   45
                                    Fault Element
• Fault element has the following sub elements:




• Value of faultcode
                                     Error                   Description
                                     VersionMismatch         Found an invalid namespace for the SOAP Envelope element
                                     MustUnderstand          An immediate child element of the Header element, with the
                                                                  mustUnderstand attribute set to "1", was not understood
                                     Client                  The message was incorrectly formed or contained incorrect
                                                                  information
                                     Server                  There was a problem with the server so the message could not
                                                                  proceed

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                                         46
                     SOAP Hand-shaking
• Example: weather services (refer to the
  link provided on course home page)




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   47
   SOAP Hand-shaking (Request)
    • Envelope contains namespaces which directs
      to the external schema
    • Body contains the request “getTemp”
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                                    Envelope
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <SOAP-ENV:Body>
   <ns1:getTemp                                                                           Body
   xmlns:ns1="urn:xmethods-Temperature"
   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
     <zipcode xsi:type="xsd:string">10016</zipcode>
   </ns1:getTemp>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>




    COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)          48
      SOAP Hand-shaking (Response)
   • Envelope contains the same namespaces
   • Body contains the payload type
     (getTempResponse), corresponding to our
     initial request
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                                     Envelope
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <SOAP-ENV:Body>
   <ns1:getTempResponse                                                                    Body
   xmlns:ns1="urn:xmethods-Temperature"
   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
     <return xsi:type="xsd:float">71.0</return>
   </ns1:getTempResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>



     COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)          49
                            SOAP over HTTP
• SOAP Request
  – Sent via HTTP GET or POST
  – HTTP POST requests specifies at least two
    HTTP headers: Content-Type and Content-
    Length.
• SOAP Response
  – Delivered by HTTP with corresponding status
    code


 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   50
                                    SOAP Request




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   51
                                SOAP Response




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   52
Universal Description, Discovery and
         Integration (UDDI)
• UDDI stores the web services providers
  and their web services provided in a
  common XML format, acted as a
  registry and database of web services
• Web-based applications interact with a
  UDDI registry using SOAP messages




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   53
            UDDI Registry Categories
            White                                          Yellow                              Green

• High-level business                        • Classification of                        • Technical info for
information                                  business and                               consuming the service
• Company name                               services                                   • Called a Type Model
• Description                                • Uses widely known                        (tModel)
• Contact info                               classification schemes                     • Defines the service’s
                                             such as NAICS,                             API, binding
• Known Identifiers                          UN/SPSC (ECMA),
(Thomas, DUNS, tax                                                                      requirements, and so
                                             SIC, and geographic                        on
ID, etc.)                                    taxonomies                                 • Usually a pointer to a
                                                                                        WSDL document


http://www.uddi.org/schema/uddi_v2.xsd

  COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                       54
            What is the role of Web
           Services for middleware?
                   2-tier                                                             3-tier

                                         Client                                                Client
                          UI                                                            UI


                                                                              Presentation Layer
            Presentation Layer


                                        Server                             Application Logic Layer
        Application Logic Layer


        Res. Management Layer                                             Res. Management Layer




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)                     55
                  More on Web Services
• We are only talking about Web services as RPC so far
  (stone age concept)!!!
• Asynchronous request/response
    –    Production and transmission of a request by a client.
    –    Consumption of the request by service provider.
    –    Production and transmission of a response by service provider.
    –    Consumption of the response by the client.

    * Can you see a collaboration activity?
    * Can you define several web services to support that? Study which
       web services should be made known to client and which should be
       made known to service provider.



  COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   56
                  More on Web Services
• WS-Coordination (a step towards asynchronous WS)
    – describes how services can make use of pre-defined coordination
      contexts to subscribe to a particular role in a collaborative activity.
• WS-Transaction (a step towards transactional WS)
    – provides a framework for incorporating transactional semantics into
      coordinated activities.
• Business Process Execution Language - BPEL (a step
  towards workflow)
    – describe how Web services are connected to create reliable and
      dependable business solutions




  COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   57
                                          References
• http://www.w3schools.com/
• Darren Barefoot, Web Services Primer, Sept 2002,
  http://www.capescience.com/education/primer/index.sht
  ml
• New to Web Services, http://www-
  106.ibm.com/developerworks/webservices/newto
• E Cerami, Web Services Essentials, O’Reilly, Feb 2002
• David S. Linthisum, B2B Application Integration,
  Addison Wesley, 2001




 COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   58
• ..\code1.JPG




COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   59
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   60
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)   61

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:4
posted:12/17/2012
language:English
pages:61