Docstoc

Web Services

Document Sample
Web Services Powered By Docstoc
					                    ISA5575 Web Techniques and Applications




                         Web Services

                                        Instructor:   Yi-Shin Chen
                                        Office: EECS 3201
                                        Email: yishin@cs.nthu.edu.tw
                                        Office Hour: Tu. 1-2PM, Th. 3-4pm




           The Challenge: A Multiplicity Of Devices

              Access Points
           Apps   Devices     Services                               Services

                                                                myInbox



                                                                     myContacts



                                                                        myCalendar



     OS independent: Windows, Windows CE, UNIX, Mac, Palm, etc.
     We want to be able to write applications that run across devices,
     and use any language
2007/5/8                Web Techniques and Applications                              2




                                                                                         1
           XML: the Lingua Franca For The
           Next Generation of Software


                           The browser has become
           XML             the universal GUI
                           XML has become the
           Web             universal data format
                           Programmable XML Web
                           Services will be come the
           GUI             universal programming
                           model between devices
           PC
2007/5/8             Web Techniques and Applications                3




           Many Standard Services are Using XML

                                       myCalendar>
                                      <myCalendar>
                                       <event>
                                        <title>…
                                        <title>…</title>
                    myCalendar            eventTime> </eventTime>
                                        <eventTime>…</eventTime>
                                       </event>
                                      </myCalendar>
                                      </myCalendar>

                                       myContacts>
                                      <myContacts>
                                               name=“ friends”
                                       <folder name=“friends”>
                                        <contact>…
                                        <contact>…</contact>
                   myContacts          </folder>
                                      </myContacts>
                                      </myContacts>

                                       <channel>
                                        <title>…
                                        <title>…</title>
                                        <item>…
                                        <item>…</item>
                                       </channel>
2007/5/8             Web Techniques and Applications                4




                                                                        2
           What are Web Services
  The term “services” means component services that
  others might use to build bigger services
  For example, some component services might
  include:
       Currency conversion
       Language translation
       Claim processing
       Authentication (like Microsoft’s Passport)
  Definition: web services are self-contained, self-
  describing, modular applications that can be
  published, located and invoked across the web


2007/5/8               Web Techniques and Applications   5




           Summary: What is a Web Service?
   Web Service:
   “software that makes services available on a
   network using technologies such as XML and
   HTTP”

   Service-Oriented Architecture (SOA):
   “development of applications from distributed
   collections of smaller loosely coupled service
   providers”

2007/5/8               Web Techniques and Applications   6




                                                             3
            Key Technologies

    Publish, Find Services:                                            UDDI
    Service Interactions:                                              SOAP
    Universal Data Format:                                              XML
    Ubiquitous Communications:                                     Internet
    Use Web Services:                                                  WSDL
      UDDI: Universal Description, Discovery, and Integration
      SOAP: Simple Object Access Protocol
      XML: eXtensible Markup Language
      WSDL: Web Services Description Language

2007/5/8                     Web Techniques and Applications                                 7




            Web Service Standards
   SOAP                                                                Service
                                                                       Provider
   WSDL
   UDDI
                                                                  sh



                                                                               Bi
                                                                 bli
                                                               Pu




                                                                                  nd




   WS-*
           WS-Addressing
                                                  Service                          Service
           WS-ReliableMessaging                   Broker                Find        User
           WS-Security, WS-Policy
           WS-Resource
           WS-Choreography (WS-CDL)
           WS-BPEL (aka. BPEL4WS)
           WS-Coordination, WS-AtomicTransaction, WS-CAF
           ...




2007/5/8                     Web Techniques and Applications                                 8




                                                                                                 4
           Web Services: Properties

   Self-contained, self-describing, modular
   component that can be published, located,
   and invoked across the Web
   Can be used either internally or exposed
   externally over the Internet
   Accessible through a standard interface
   Allows heterogeneous systems to work
   together as a single web of computation

2007/5/8                Web Techniques and Applications   9




           Web Service Scenario
    Provider builds and defines the service in WSDL
           http://www.w3.org/TR/wsdl
    Provider registers the service in UDDI
           http://www.uddi.org/specification.html
    User finds the service by searching UDDI registry
    User application binds to the Web service and
    invokes its operations via SOAP




2007/5/8                Web Techniques and Applications   10




                                                               5
           Web Service Architecture

                                                     Service
    Interactions:   SOAP                             Provider

           Data:   XML




                                                hs
  Communication:     HTTP



                                             bli




                                                                Bi
                                                                   nd
                                           Pu
                                 Service                                Service
                                 Broker                 Find             User



2007/5/8                    Web Techniques and Applications                       11




           Web Services Protocols
                                  Find a Service
                                http://www.uddi.org                       UDDI
                            Link to discovery document

                                  Discovery
                              http://yourservice.com
  Web                         HTML with link to WSDL
 Service
Consumer                 How do we talk? (WSDL)
                          http://yourservice.com/?WSDL                    Web
                          return service descriptions (XML)              Service
                    Let me talk to you (SOAP)
                            http://yourservice.com/svc1
                           return service response (XML)

2007/5/8                    Web Techniques and Applications                       12




                                                                                       6
           Building Web Services
   Commercial Offerings
           Microsoft's .NET
             http://microsoft.com/net
           IBM's WebSphere
             http://www.ibm.com/websphere
           Sun's J2EE
             http://java.sun.com/j2ee
   Standards
           SOAP http://www.w3.org/TR/SOAP
           WSDL http://www.w3.org/TR/WSDL
           UDDI http://www.uddi.org

2007/5/8                   Web Techniques and Applications   13




           .Net Example Output




2007/5/8                   Web Techniques and Applications   14




                                                                  7
           .Net Example Output (Contd.)




2007/5/8          Web Techniques and Applications   15




           .Net Example Output (Contd.)




2007/5/8          Web Techniques and Applications   16




                                                         8
           SOAP
   Used to be “Simple Object Access
   Protocol”,
   but



   Processing Model
   Data Representation and RPC
   Binding to transport protocols (e.g. HTTP)

2007/5/8                   Web Techniques and Applications                   17




           Simple Object Access Protocol
   Purpose of SOAP
           to use the Internet to interact with remote applications
              HTTP was not designed for the above purpose
              Usually done using Remote Procedure Calls (RPC), or
              Microsoft’s Distributed Component Object Model (DCOM), or
              the Internet Inter-Orb Protocol (IIOP) and others
                 These work well over LANs but over the Internet they have
                 many problems




2007/5/8                   Web Techniques and Applications                   18




                                                                                  9
           The Trouble with Firewalls
   In the TCP/IP architecture, each protocol is
   assigned a unique port number
           Most firewalls block traffic according to port number
           Distributed object protocols don’t have a single port
           assignment, they use dynamically assigned ports
   SOAP adds a distributed object protocol on top
   of the HTTP protocol
           SOAP uses XML to define the format of
           request/response messages and then allows the
           HTTP POST command to send the info


2007/5/8                  Web Techniques and Applications            19




           What is SOAP
   SOAP is
           A distributed object protocol which allows RPCs
           A lightweight mechanism for exchanging structured and typed
           information between systems using XML
   It consists of three parts
           The SOAP envelope: define what is in a message, who
           should deal with it, and whether it is optional or mandatory
           SOAP encoding rules for exchanging instances of application-
           defined datatypes
           SOAP RPC defines a convention used to represent remote
           procedure calls and responses




2007/5/8                  Web Techniques and Applications            20




                                                                          10
           Sample SOAP Request
POST /HelloTest/Service1.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction:
 "http://formosa.nthu.edu.tw/webservices/H
 elloWorld"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope Techniques and Applications
2007/5/8      Web                                             21




           Sample SOAP Reply
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-
   instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
  <HelloWorldResponse
   xmlns="http://formosa.nthu.edu.tw/webservices/">
    <HelloWorldResult>string</HelloWorldResult>
  </HelloWorldResponse>
 </soap:Body>
</soap:Envelope>

2007/5/8               Web Techniques and Applications        22




                                                                   11
           SOAP Messages Have 3 Components

   A SOAP message is an XML document
   containing a mandatory SOAP envelope, an
   optional SOAP header and a mandatory SOAP
   body
           The envelope is the top element of the XML
           document
           The header is a generic way to add features to a
           SOAP message
           The body is a container for mandatory information




2007/5/8                 Web Techniques and Applications       23




           SOAP Template
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Header>
... Header information goes here ...
</soap:Header>
<soap:Body>
... Body information goes here ...
</soap:Body>
<soap:Fault>
... Fault information goes here ...
</soap:Fault>
</soap:Envelope>




2007/5/8                 Web Techniques and Applications       24




                                                                    12
           The Envelope Element
   Must be the root element of a SOAP message
   Define the XML document as a SOAP message
   Set the namespace
           <?xml version="1.0" encoding="utf-8"?>
           <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-
             instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
            <soap:Body>
              <HelloWorld xmlns="http://formosa.usc.edu/webservices/">
               <InputStr>string</InputStr>
              </HelloWorld>
            </soap:Body>
           </soap:Envelope>



2007/5/8                  Web Techniques and Applications                25




           Header Element
   Can contain additional application specific
   information about the SOAP message
   Example where the header contains info about
   the transaction data
     <env:Header
         xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
     <t:Transaction xmlns:t="http://example.org/2001/06/tx"
               env:mustUnderstand="true" >
       5
     </t:Transaction>
     </env:Header>


2007/5/8                  Web Techniques and Applications                26




                                                                              13
           Body Element
   Must be present in a SOAP message
   Example
           <soap:Body>
           <GetPrice>
            <Item>Apples</Item>
           </GetPrice>
           </soap:Body>




2007/5/8                Web Techniques and Applications          27




           Fault Element
   Used to provide information about errors that
   occurred while processing the message
   Example
           <env:Fault>
            <env:Code>
             <env:Value>env:Sender</env:Value>
             <env:Subcode>
              <env:Value>m:MessageTimeout</env:Value>
             </env:Subcode>
            </env:Code>
            <env:Reason>
             <env:Text xml:lang="en">Sender Timeout</env:Text>
            </env:Reason>
           </env:Fault>
2007/5/8                Web Techniques and Applications          28




                                                                      14
           WSDL Structure

Types              Data type definitions
Message            Signature of request and reply for
                   each method (≈ IDL)
Port Type          <service, protocol> operations
Operation          method     messages
Binding            Protocol and data-format specification

Service            { Port  binding }
Port               Address (≈ URL)


2007/5/8          Web Techniques and Applications       29




           WSDL Example (Cont.)
<?xml version="1.0" encoding="utf-8"?>
<definitions
   xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/
   " xmlns:s="http://www.w3.org/2001/XMLSchema"
   xmlns:s0="http://formosa.nthu.edu.tw/webservices/"
   xmlns:soapenc="http://schemas.xmlsoap.org/soap/e
   ncoding/"
   xmlns:tm="http://microsoft.com/wsdl/mime/textMatch
   ing/"
   xmlns:mime="http://schemas.xmlsoap.org/wsdl/mim
   e/"
   targetNamespace="http://formosa.nthu.edu.tw/webs
2007/5/8            Web Techniques and Applications   30
   ervices/"




                                                             15
           WSDL Example (Cont.)
<s:element name="HelloWorld">
    <s:complexType>
      <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="InputStr"
  type="s:string" />
      </s:sequence>
    </s:complexType>
   </s:element>
   <s:element name="HelloWorldResponse">
    <s:complexType>
      <s:sequence>
       <s:element minOccurs="0" maxOccurs="1"
  name="HelloWorldResult" type="s:string" />
      </s:sequence>
    </s:complexType>
   </s:element>
2007/5/8               Web Techniques and Applications                31




           WSDL Example (Cont.)
<s:element name="ByeWorld">
    <s:complexType>
      <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="InputStr"
  type="s:string" />
      </s:sequence>
    </s:complexType>
   </s:element>
   <s:element name="ByeWorldResponse">
    <s:complexType>
      <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="ByeWorldResult"
  type="s:string" />
      </s:sequence>
    </s:complexType>
   </s:element>
 </s:schema>
</types>

2007/5/8               Web Techniques and Applications                32




                                                                           16
           WSDL Example (Cont.)
<message name="HelloWorldSoapIn">
 <part name="parameters" element="s0:HelloWorld" />
</message>
<message name="HelloWorldSoapOut">
 <part name="parameters" element="s0:HelloWorldResponse" />
</message>
<message name="ByeWorldSoapIn">
 <part name="parameters" element="s0:ByeWorld" />
</message>
<message name="ByeWorldSoapOut">
 <part name="parameters" element="s0:ByeWorldResponse" />
</message>
<portType name="Service1Soap">
 <operation name="HelloWorld">
  <input message="s0:HelloWorldSoapIn" />
  <output message="s0:HelloWorldSoapOut" />
 </operation>
 <operation name="ByeWorld">
  <input message="s0:ByeWorldSoapIn" />
  <output message="s0:ByeWorldSoapOut" />
 </operation>
</portType>
2007/5/8                        Web Techniques and Applications                              33




           WSDL Example (Cont.)
 <binding name="Service1Soap" type="s0:Service1Soap">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
  <operation name="HelloWorld">
   <soap:operation soapAction="http://formosa.usc.edu/webservices/HelloWorld" style="document"
    />
   <input> <soap:body use="literal" /></input>
   <output><soap:body use="literal" /></output>
  </operation>
  <operation name="ByeWorld">
   <soap:operation soapAction="http://formosa.usc.edu/webservices/ByeWorld" style="document" />
   <input>
     <soap:body use="literal" />
   </input>
   <output>
     <soap:body use="literal" />
   </output>
  </operation>
 </binding>
 <service name="Service1">
  <port name="Service1Soap" binding="s0:Service1Soap">
   <soap:address location="http://localhost/HelloTest/Service1.asmx" />
  </port>
 </service>
</definitions>
2007/5/8                        Web Techniques and Applications                              34




                                                                                                  17
           UDDI
   Universal Description, Discovery, and
   Integration



   static / dynamic discovery                           SERVICE
   public / private registries                          REGISTRY

                                               find                  publish


                                         SERVICE                     SERVICE
                                          USER           messages   PROVIDER

2007/5/8                   Web Techniques and Applications                     35




           More about UDDI
   UDDL is a registry that is intended to contain a
   repository of web services where users can search for a
   web service
   The search would return a DISCO document, which is an
   XML document that provides the location of the WSDL
   document for the given web service
   Before 2006, UDDI Business Registries (UBR) could be
   found at:
           http://www.uddi.org/find.html
           But, “IBM, Microsoft and SAP have evaluated the status of the
           UDDI Business Registry and determined that the goals for the
           project have been achieved. Given this, the UDDI Business
           Registry will be discontinued as of 12 January 2006”

2007/5/8                   Web Techniques and Applications                     36




                                                                                    18
           UDDI Descriptions
   publisherAssertion
   (describes relations between businesses)

   businessEntity
   (describes a concrete business)

   businessService
   (describes a Web service)

   bindingTemplate
   (describes invocation information)

   tModel
   (technical details, e.g. reference to WSDL description)
2007/5/8                      Web Techniques and Applications                         37




           UDDI Example
   Query placed inside the body of a SOAP envelope returns
   details about the company Microsoft
           <find_business generic=“1.0”
           Xmlns=“urn:uddi-org:api”>
              <name>Microsoft</name>
           </find_business>
   Result listing of <businessInfo>elements currently registered
   for Microsoft
           <businessList generic="1.0" operator="Microsoft Corporation" truncated="false"
           xmlns="urn:uddi-org:api">
           <businessInfos>
            <businessInfo businessKey="0076B468-EB27-42E5-AC09-
             9955CFF462A3">
            <name>Microsoft Corporation</name>
             <description xml:lang="en"> Empowering people through great software -
             any time, any place and on any device is Microsoft's vision. As the
             worldwide leader in software for personal and business computing, we strive
             to produce innovative products and services that meet our customer's
             </description> <serviceInfos>


2007/5/8                      Web Techniques and Applications                         38




                                                                                            19
           UDDI Example (Cont.)
<serviceInfo businessKey="0076B468-EB27-42E5-AC09-
   9955CFF462A3"                 serviceKey="1FFE1F71-2AF3-45FB-B788-
   09AF7FF151A4">
 <name>Web services for smart searching</name>
</serviceInfo>
<serviceInfo businessKey="0076B468-EB27-42E5-AC09-9955CFF462A3"
   serviceKey="8BF2F51F-8ED4-43FE-B665-38D8205D1333">
 <name>Electronic Business Integration Services</name>
</serviceInfo>
<serviceInfo businessKey="0076B468-EB27-42E5-AC09-9955CFF462A3"
   serviceKey="611C5867-384E-4FFD-B49C-28F93A7B4F9B">
 <name>Volume Licensing Select Program</name>
</serviceInfo>
<serviceInfo businessKey="0076B468-EB27-42E5-AC09-9955CFF462A3"
   serviceKey="A8E4999A-21A3-47FA-802E-EE50A88B266F">
<name>UDDI Web Sites</name> </serviceInfo>
</serviceInfos> </businessInfo> </businessInfos> </businessList>



2007/5/8                Web Techniques and Applications                 39




           Famous Web Services

   Google Search Tools
           http://code.google.com/
   Yahoo! Search Tools
           http://developer.yahoo.com/about/




2007/5/8                Web Techniques and Applications                 40




                                                                             20
           RSS Example
<?xml version="1.0"?><rss version="2.0"> <channel>
  <title>Liftoff News</title> <link>http://liftoff.msfc.nasa.gov/</link>
  <description>Liftoff to Space Exploration.</description>
  <language>en-us</language><pubDate></pubDate><lastBuildDate></lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Weblog Editor 2.0</generator>
   <managingEditor>editor@example.com</managingEditor>
  <webMaster>webmaster@example.com</webMaster>

  <item> <title>Star City</title>
   <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
   <description>How do Americans get ready to work with Russians?</description>
   <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
   <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid></item>

   <item><title>Astronauts' Dirty Laundry</title>
    <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
    <description>the International Space Station has many luxuries.</description>
    <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
    <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid> </item>
</channel></rss>
2007/5/8                     Web Techniques and Applications                        41




                                                                                         21

				
DOCUMENT INFO
Shared By:
Stats:
views:44
posted:8/21/2011
language:English
pages:21
Description: Web Services Description Language acronym is used to describe a Web service and how to communicate with Web Services XML language. Interface to provide users with detailed instructions.