SlideShare una empresa de Scribd logo
1 de 40
Remote Procedure Calls
and Web Services



                                  Zachary G. Ives
                               University of Pennsylvania
              CIS 455 / 555 – Internet and Web Systems



                                       March 3, 2009
Today
 Reminder HW2 Milestone 1 due tonight

 Distributed programming, concluded:
  RPC and Web Services




                                         2
Some Common Modes of
Building Distributed
Applications
Data-intensive:
    XQuery (fetch XML from multiple sites, produce new XML)
        Turing-complete functional programming language
        Good for Web Services; not much support for I/O, etc.
    MapReduce (built over DHT or distributed file system)
        Single filter (map), followed by single aggregation (reduce)
        Languages over it: Sawzall, Pig Latin, Dryad, …
Message passing / request-response:
        e.g., over a DHT, sockets, or message queue
    Communication via asynchronous messages
    Processing in message handler loop
Function calls:
    Remote procedure call / remote method invocation
                                                                        3
Fully Synchronous
Request/Response: Remote
Procedure Calls
 Remote procedure calls have been around forever, including:
       COM+
   
       CORBA
   
       Java RMI
   
       The basic idea: put a function elsewhere in the system, call in
   
       distributed fashion but using standard languages, methods
 An RPC API defines a format for:
    Initiating a call on a particular server, generally in a reliable way
    Sending parameters (marshalling) to the server
    Receiving a return value, which may require marshalling as well
 And an RPC call is synchronous (i.e., it generally blocks)


                                                                             4
A Remote Procedure Call Visualized

                                                server waits for req.
                                     function
                 server is busy
RPC
Server
                       t
                    ues
                 req


RPC
Client working             client blocks

                              time



                                                                        5
How RPC Generally Works
 You write an application with a series of functions
 One of these functions, F, will be distributed remotely
 You call a “stub generator”
    A caller stub emulates the function F:
        Opens a connection to the server
        Requests F, marshalling all parameters
        Receives F’s return status and parameters
    A server stub emulates the caller:
        Receives a request for F with parameters
        Unmarshals the parameters, invokes F
        Takes F’s return status (e.g., protection fault), return value, and marshals
         it back to the client



                                                                                        6
Passing Value Parameters
 Steps involved in doing remote computation through RPC

                            2-8




                                                           7
RPC Components
 Generally, you need to write:
    Your function, in a compatible language
    An interface definition, analogous to a C header file, so
     other people can program for F without having its source
 Generally, software will take the interface definition
  and generate the appropriate stubs
     (In the case of Java, RMIC knows enough about Java to
     run directly on the source file)
 The server stubs will generally run in some type of
  daemon process on the server
    Each function will need a globally unique name or GUID

                                                                 8
Parameter Passing Can Be Tricky
Because of References
 The situation when passing an object by reference or by value.


                                 2-18




                                                                   9
What Are the Hard Problems with
RPC? Esp. Inter-Language RPC?

 Resolving different data formats between languages
  (e.g., Java vs. Fortran arrays)
 Reliability, security

 Finding remote procedures in the first place
 Extensibility/maintainability

 (Some of these might look familiar from when we
  talked about data exchange!)

                                                       10
Web Services
 Goal: provide an infrastructure for connecting components,
  building applications in a way similar to hyperlinks between
  data
 It’s another distributed computing platform for the Web
    Goal: Internet-scale, language-independent, upwards-compatible where
     possible
 This one is based on many familiar concepts
    Standard protocols: HTTP
    Standard marshalling formats: XML-based, XML Schemas
    All new data formats are XML-based




                                                                       11
Three Parts to Web Services
1. “Wire” / messaging protocols
       Data encodings, RPC calls or document passing, etc.
   
2. Describing what goes on the wire
       Schemas for the data
   
3. “Service discovery”
       Means of finding web services
   




                                                             12
The Protocol Stacks of Web Services
                                                                                  High-level
                        WS-AtomicTransaction,
                                                           Orchestration
Other extensions                                                                  state transition
                          WS-Coordination
                                                           (WS-BPEL)              + msging
                            WS-Addressing
SOAP Attachments                                              Message             diagrams
                                                            Sequencing            between
     WS-Security
                                                        Service Capabilities      modules
                                                         (WS-Capability)
                                                        Service Description       Directory
          SOAP, XML-RPC
                                                              (WSDL)              (UDDI)
                   XML                                    XML Schema              Inspection
          Wire Format Stack                             Description Stack      Discovery Stack


  Enhanced + expanded from a figure from IBM’s “Web Services Insider”,
  http://www-106.ibm.com/developerworks/webservices/library/ws-ref2/


                                                                                               13
Messaging Protocol: SOAP
 Simple Object Access Protocol: XML-based format for
  passing parameters
    Has a SOAP header and body inside an envelope
    As a defined HTTP binding (POST with content-type of
     application/soap+xml)
    A companion SOAP Attachments encapsulates other (MIME) data

    The header defines information about processing: encoding, signatures,
     etc.
        It’s extensible, and there’s a special attribute called mustUnderstand that
         is attached to elements that must be supported by the callee
    The body defines the actual application-defined data



                                                                                   14
A SOAP Envelope
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV=“http://www.w3.org/2001/12/soap-envelope”
  xmlns:xsd=“http://www.w3.org/www.w3.org/2001/XMLSchema-instance”>
  <SOAP-ENV:Header>
     <t:Transaction xmlns:t=“www.mytrans.com” SOAP-
     ENV:mustUnderstand=“1” />
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
     <m:PlaceOrder xmlns:m=“www.somewhere/there”>
      <orderno xsi:type=“xsd:string”>12</orderno>
     </m:PlaceOrder>
   </SOAP-ENV:Body>
</SOAP-ENV: Envelope>


                                                                  15
Making a SOAP Call
 To execute a call to service PlaceOrder:

   POST /PlaceOrder HTTP/1.1
   Host: my.server.com
   Content-Type: application/soap+xml; charset=“utf-8”
   Content-Length: nnn

   <SOAP-ENV:Envelope>
     …
   </SOAP-ENV:Envelope>


                                                         16
SOAP Return Values
 If successful, the SOAP response will generally be another
  SOAP message with the return data values, much like the
  request
 If failure, the contents of the SOAP envelop will generally be
  a Fault message, along the lines of:

   <SOAP-ENV:Body>
     <SOAP-ENV:Fault xmlns=“mynamespace”>
      <faultcode>SOAP-ENV:Client</faultcode>
      <faultstring>Could not parse message</faultstring>
   …



                                                                   17
How Do We Declare Functions?
 WSDL is the interface definition language for web
  services
    Defines notions of protocol bindings, ports, and services
    Generally describes data types using XML Schema

 In CORBA, this was called an IDL
 In Java, the interface uses the same language as the
  Java code



                                                                 18
A WSDL Service

                Service

                             Port
    Port         Port
                           PortType
   PortType    PortType
                           Operation
   Operation   Operation

                           Operation
   Operation   Operation



                           Binding
   Binding     Binding

                                       19
Web Service Terminology
 Service: the entire Web Service
 Port: maps a set of port types to a transport binding
  (a protocol, frequently SOAP, COM, CORBA, …)
 Port Type: abstract grouping of operations, i.e. a
  class
 Operation: the type of operation –
  request/response, one-way
    Input message and output message; maybe also fault
     message
 Types: the XML Schema type definitions

                                                          20
Example WSDL
<service name=“POService”>
     <port binding=“my:POBinding”>
          <soap:address location=“http://yyy:9000/POSvc”/>
     </port>
</service>
<binding xmlns:my=“…” name=“POBinding”>
     <soap:binding style=“rpc” transport=“http://www.w3.org/2001/...” />
     <operation name=“POrder”>
         <soap:operation soapAction=“POService/POBinding” style=“rpc” />
         <input name=“POrder”>
              <soap:body use=“literal” … namespace=“POService” …/>
         </input>
         <output name=“POrderResult”>
              <soap:body use=“literal” … namespace=“POService” …/>
         </output>
     </operation>
</binding>
                                                                           21
JAX-RPC: Java and Web
Services
 To write JAX-RPC web service “endpoint”, you
  need two parts:
     An endpoint interface – this is basically like the IDL
      statement
     An implementation class – your actual code

public interface BookQuote extends java.rmi.Remote {
   public float getBookPrice(String isbn) throws java.rmi.RemoteException;
}
public class BookQuote_Impl_1 implements BookQuote {
   public float getBookPrice(String isbn) { return 3.22; }
}


                                                                             22
Different Options for Calling
 The conventional approach is to generate a stub, as
  in the RPC model described earlier
 You can also dynamically generate the call to the
  remote interface, e.g., by looking up an interesting
  function to call
 Finally, the “DII” (Dynamic Instance Invocation)
  method allows you to assemble the SOAP call on
  your own



                                                         23
Creating a Java Web Service
 A compiler called wscompile is used to generate
  your WSDL file and stubs
    You need to start with a configuration file that says
     something about the service you’re building and the
     interfaces that you’re converting into Web Services




                                                             24
Example Configuration File
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<configuration xmlns=quot;http://java.sun.com/xml/ns/jax-
  rpc/ri/configquot;>
   <service name=quot;StockQuotequot;
     targetNamespace=quot;http://example.com/stockquote.wsdlquot;
     typeNamespace=quot;http://example.com/stockquote/typesquot;
     packageName=quot;stockqtquot;>

       <interface name=quot;stockqt.StockQuoteProviderquot;
         servantName=quot;stockqt.StockQuoteServiceImplquot;/>

   </service>
</configuration>


                                                            25
Starting a WAR
 The Web Service version of a Java JAR file is a Web Archive,
  WAR
 There’s a tool called wsdeploy that generates WAR files
 Generally this will automatically be called from a build tool
  such as Ant
 Finally, you may need to add the WAR file to the appropriate
  location in Apache Tomcat (or WebSphere, etc.) and enable
  it

 See
  http://java.sun.com/developer/technicalArticles/WebServices/WSPa
   for a detailed example

                                                              26
Finding a Web Service
 UDDI: Universal Description, Discovery, and
  Integration registry
 Think of it as DNS for web services
    It’s a replicated database, hosted by IBM, HP, SAP, MS


 UDDI takes SOAP requests to add and query web
  service interface data




                                                              27
What’s in UDDI
White pages:
    Information about business names, contact info, Web site name, etc.
Yellow pages:
    Types of businesses, locations, products
    Includes predefined taxonomies for location, industry, etc.
Green pages – what we probably care the most about:
    How to interact with business services; business process definitions;
     etc
    Pointer to WSDL file(s)
    Unique ID for each service




                                                                             28
Data Types in UDDI
 businessEntity: top-level structure describing info
  about the business
 businessService: name and description of a service
 bindingTemplate: how to access the service
 tModel (t = type/technical): unique identifier for
  each service-template specification
 publisherAssertion: describes relationship between
  businessEntities (e.g., department, division)



                                                        29
Relationships between UDDI
Structures



publisherAssertion
         n
         2                                             tModel
  businessEntity                                        n
             1
                                                  m
                   n
                               1   n bindingTemplate
             businessService

                                                                30
Example UDDI businessEntity
<businessEntity businessKey=“0123…” xmlns=“urn:uddi-org:api_v2”>
    <discoveryURLs>
         <discoveryURL useType=“businessEntity”>
              http://uddi.ibm.com/registery/uddiget?businessKey=0123...
         </discoveryURL>
    <name>My Books</name>
    <description>Technical Book Wholesaler</description>
    …
    <businessServices>
         …
    </businessServices>
    <identifierBag>
         <!– keyedReferences to tModels 
    </identifierBag>
    <categoryBag> … </categoryBag>
</businessEntity>
                                                                          31
UDDI in Perspective
 Original idea was that it would just organize itself in
  a way that people could find anything they wanted

 Today UDDI is basically a very simple catalog of
  services, which can be queried with standard APIs
    It’s not clear that it really does what people really want:
     they want to find services “like Y” or “that do Z”




                                                                   32
The Problem: With UDDI and Plenty
of Other Situations
There’s no universal, unambiguous way of describing “what I
  mean”
    Relational database idea of “normalization” doesn’t convert concepts
     into some normal form – it just helps us cluster our concepts in
     meaningful ways
    “Knowledge representation” tries to encode definitions clearly – but
     even then, much is up to interpretation


The best we can do: describe how things relate
    pollo = chicken = poulet = 雞 = 鸡 = jī = मु ग ी = murg
    Note that this mapping may be imprecise or situation-specific!
        Calling someone a chicken, vs. a chicken that’s a bird


                                                                            33
This Brings Us Back to XQuery,
Whose Main Role Is to Relate
XML
Suppose we define an XML schema for our target data and our source data

A view is a stored query
     Function from a set of (XML) sources to an XML output
     In fact, in XQuery, a view is actually called a function
Can directly translate between XML schemas or structures
     Describes a relationship between two items
          Transform 2 into 6 by “add 4” operation
          Convert from S1 to S2 by applying the query described by view V

Often, we don’t need to transfer all data – instead, we want to use the data at
   one source to help answer a query over another source…




                                                                              34
Lazy Evaluation: A Virtual View
                                            Browser/App
                           Server(s)

  Source1.xml                      XQuery
                           Virtual            Query
           XQuery
                          XML doc.            Form
  Source2.xml



 Source1.xml
                                       XSLT
                             Query
               Composed                       HTML
                             Results
               XQuery
 Source2.xml

                                                          35
Let’s Look at Some Simple
Mappings

 Beginning with examples of using XQuery to convert
  from one schema to another, e.g., to import data

 First: let’s review what our XQuery mappings need
  to accomplish…




                                                      36
Challenges of Mapping Schemas
In a perfect world, it would be easy to match up items from one
   schema with another
    Each element would have a simple correspondence to an element in
     the other schema
    Every value would clearly map to a value in the other schema
Real world: as with human languages, things don’t map clearly!
       Different decompositions into elements
   
       Different structures
   
       Tag name vs. value
   
       Values may not exactly correspond
   
       It may be unclear whether a value is the same
   
It’s a tough job, but often things can be mapped


                                                                        37
Example Schemas
Bob’s Movie Database            Mary’s Art List
  <movie>                         <workOfArt>
   <title>…</title>                <id>…</id>
   <year>…</year>                  <type>…</type>
   <director>…</director>          <artist>…</artist>
   <editor>…</editor>              <subject>…</subject>
   <star>…</star>*                 <title>…</title>
  </movie>*                       </workOfArt>*




  Want to map data from one schema to the other
                                                          38
Mapping Bob’s Movies  Mary’s Art

Start with the schema of the output as a template:
  <workOfArt>
    <id>$i</id>
    <type>$y</type>
    <artist>$a</artist>
    <subject>$s</subject>
    <title>$t</title>
  </workOfArt>
Then figure out where to find the values in the source,
  and create XPaths


                                                      39
The Final Schema Mapping
Mary’s Art  Bob’s Movies
    for $m in doc(“movie.xml”)//movie,
        $a in $m/director/text(),
        $i in $m/title/text(),
        $t in $m/title/text()
    return <workOfArt>
             <id>$i</id>
             <type>movie</type>    Note the absence of subject…
             <artist>$a</artist>
                                   We had no reasonable source,
             <title>$t</title>
                                   so we are leaving it out.
            </workOfArt>




                                                             40

Más contenido relacionado

La actualidad más candente

La actualidad más candente (19)

Web server
Web serverWeb server
Web server
 
SOAP WEB TECHNOLOGIES
SOAP WEB TECHNOLOGIESSOAP WEB TECHNOLOGIES
SOAP WEB TECHNOLOGIES
 
Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web Services
 
RPC protocols
RPC protocolsRPC protocols
RPC protocols
 
Web service introduction 2
Web service introduction 2Web service introduction 2
Web service introduction 2
 
Web service introduction
Web service introductionWeb service introduction
Web service introduction
 
Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication Foundation
 
Wsdl
WsdlWsdl
Wsdl
 
GRPC 101 - DevFest Belgium 2016
GRPC 101 - DevFest Belgium 2016GRPC 101 - DevFest Belgium 2016
GRPC 101 - DevFest Belgium 2016
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzz
 
CoAP in Reactive Blocks
CoAP in Reactive BlocksCoAP in Reactive Blocks
CoAP in Reactive Blocks
 
The constrained application protocol (CoAP)
The constrained application protocol (CoAP)The constrained application protocol (CoAP)
The constrained application protocol (CoAP)
 
HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPC
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
The constrained application protocol (coap) part 3
The constrained application protocol (coap)  part 3The constrained application protocol (coap)  part 3
The constrained application protocol (coap) part 3
 
Distributed Reactive Services with Reactor & Spring - Stéphane Maldini
Distributed Reactive Services with Reactor & Spring - Stéphane MaldiniDistributed Reactive Services with Reactor & Spring - Stéphane Maldini
Distributed Reactive Services with Reactor & Spring - Stéphane Maldini
 
The constrained application protocol (coap) part 3
The constrained application protocol (coap)  part 3The constrained application protocol (coap)  part 3
The constrained application protocol (coap) part 3
 
The constrained application protocol (coap) part 2
The constrained application protocol (coap)  part 2The constrained application protocol (coap)  part 2
The constrained application protocol (coap) part 2
 
CoAP protocol -Internet of Things(iot)
CoAP protocol -Internet of Things(iot)CoAP protocol -Internet of Things(iot)
CoAP protocol -Internet of Things(iot)
 

Destacado

Ryan Vincent E Folio 2009
Ryan Vincent E Folio 2009Ryan Vincent E Folio 2009
Ryan Vincent E Folio 2009
rjvnatl
 
Susan Siferd Work Samples
Susan Siferd Work SamplesSusan Siferd Work Samples
Susan Siferd Work Samples
SusanSiferd
 
Portfolio Presentation #3
Portfolio Presentation #3Portfolio Presentation #3
Portfolio Presentation #3
Michaela_Kiley
 
John Kozak On One Multimedia Productions Website Design Project
John Kozak On One Multimedia Productions Website Design ProjectJohn Kozak On One Multimedia Productions Website Design Project
John Kozak On One Multimedia Productions Website Design Project
John Kozak
 
On One Productions Multimedia Website Design Project
On One Productions Multimedia Website Design ProjectOn One Productions Multimedia Website Design Project
On One Productions Multimedia Website Design Project
John Kozak
 

Destacado (18)

Just How Much Do You Know About Mardi
Just How Much Do You Know About MardiJust How Much Do You Know About Mardi
Just How Much Do You Know About Mardi
 
Ryan Vincent E Folio 2009
Ryan Vincent E Folio 2009Ryan Vincent E Folio 2009
Ryan Vincent E Folio 2009
 
Unidad 1
Unidad 1Unidad 1
Unidad 1
 
Kiley P.Pt.2
Kiley P.Pt.2Kiley P.Pt.2
Kiley P.Pt.2
 
Ryan Vincent Photo Art Direction
Ryan Vincent Photo Art DirectionRyan Vincent Photo Art Direction
Ryan Vincent Photo Art Direction
 
Susan Siferd Work Samples
Susan Siferd Work SamplesSusan Siferd Work Samples
Susan Siferd Work Samples
 
TICs
TICsTICs
TICs
 
Portfolio Presentation #3
Portfolio Presentation #3Portfolio Presentation #3
Portfolio Presentation #3
 
Presentation4
Presentation4Presentation4
Presentation4
 
Presentation
PresentationPresentation
Presentation
 
Alter'd
Alter'dAlter'd
Alter'd
 
An Industry In Change (Oaa)
An Industry In Change (Oaa)An Industry In Change (Oaa)
An Industry In Change (Oaa)
 
John Kozak On One Multimedia Productions Website Design Project
John Kozak On One Multimedia Productions Website Design ProjectJohn Kozak On One Multimedia Productions Website Design Project
John Kozak On One Multimedia Productions Website Design Project
 
Portfolio Parts 1&2
Portfolio Parts 1&2Portfolio Parts 1&2
Portfolio Parts 1&2
 
Personal Safety & Awareness
Personal Safety & AwarenessPersonal Safety & Awareness
Personal Safety & Awareness
 
Resume
ResumeResume
Resume
 
On One Productions Multimedia Website Design Project
On One Productions Multimedia Website Design ProjectOn One Productions Multimedia Website Design Project
On One Productions Multimedia Website Design Project
 
John Kozak Creative Brief
John Kozak Creative BriefJohn Kozak Creative Brief
John Kozak Creative Brief
 

Similar a ghfghg

Intro to web services
Intro to web servicesIntro to web services
Intro to web services
Neil Ghosh
 
Writing & Using Web Services
Writing & Using Web ServicesWriting & Using Web Services
Writing & Using Web Services
Rajarshi Guha
 
FlowER Erlang Openflow Controller
FlowER Erlang Openflow ControllerFlowER Erlang Openflow Controller
FlowER Erlang Openflow Controller
Holger Winkelmann
 
Rpc (Distributed computing)
Rpc (Distributed computing)Rpc (Distributed computing)
Rpc (Distributed computing)
Sri Prasanna
 
Application Services On The Web Sales Forcecom
Application Services On The Web Sales ForcecomApplication Services On The Web Sales Forcecom
Application Services On The Web Sales Forcecom
QConLondon2008
 
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
QAware GmbH
 
WSF PHP 2 Webinar Sep 2008
WSF PHP 2 Webinar Sep 2008WSF PHP 2 Webinar Sep 2008
WSF PHP 2 Webinar Sep 2008
WSO2
 

Similar a ghfghg (20)

Intro to web services
Intro to web servicesIntro to web services
Intro to web services
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
SOA and web services
SOA and web servicesSOA and web services
SOA and web services
 
ReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... YawnReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... Yawn
 
Writing & Using Web Services
Writing & Using Web ServicesWriting & Using Web Services
Writing & Using Web Services
 
Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289
 
FlowER Erlang Openflow Controller
FlowER Erlang Openflow ControllerFlowER Erlang Openflow Controller
FlowER Erlang Openflow Controller
 
Web services
Web servicesWeb services
Web services
 
Rpc (Distributed computing)
Rpc (Distributed computing)Rpc (Distributed computing)
Rpc (Distributed computing)
 
#lspe: Dynamic Scaling
#lspe: Dynamic Scaling #lspe: Dynamic Scaling
#lspe: Dynamic Scaling
 
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
 
Application Services On The Web Sales Forcecom
Application Services On The Web Sales ForcecomApplication Services On The Web Sales Forcecom
Application Services On The Web Sales Forcecom
 
Apache Spark Streaming
Apache Spark StreamingApache Spark Streaming
Apache Spark Streaming
 
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ... The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
 
Real-Time with Flowdock
Real-Time with FlowdockReal-Time with Flowdock
Real-Time with Flowdock
 
A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)
 
OpenStack and OpenFlow Demos
OpenStack and OpenFlow DemosOpenStack and OpenFlow Demos
OpenStack and OpenFlow Demos
 
WSF PHP 2 Webinar Sep 2008
WSF PHP 2 Webinar Sep 2008WSF PHP 2 Webinar Sep 2008
WSF PHP 2 Webinar Sep 2008
 
Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 

ghfghg

  • 1. Remote Procedure Calls and Web Services Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems March 3, 2009
  • 2. Today  Reminder HW2 Milestone 1 due tonight  Distributed programming, concluded: RPC and Web Services 2
  • 3. Some Common Modes of Building Distributed Applications Data-intensive:  XQuery (fetch XML from multiple sites, produce new XML)  Turing-complete functional programming language  Good for Web Services; not much support for I/O, etc.  MapReduce (built over DHT or distributed file system)  Single filter (map), followed by single aggregation (reduce)  Languages over it: Sawzall, Pig Latin, Dryad, … Message passing / request-response:  e.g., over a DHT, sockets, or message queue  Communication via asynchronous messages  Processing in message handler loop Function calls:  Remote procedure call / remote method invocation 3
  • 4. Fully Synchronous Request/Response: Remote Procedure Calls  Remote procedure calls have been around forever, including: COM+  CORBA  Java RMI  The basic idea: put a function elsewhere in the system, call in  distributed fashion but using standard languages, methods  An RPC API defines a format for:  Initiating a call on a particular server, generally in a reliable way  Sending parameters (marshalling) to the server  Receiving a return value, which may require marshalling as well  And an RPC call is synchronous (i.e., it generally blocks) 4
  • 5. A Remote Procedure Call Visualized server waits for req. function server is busy RPC Server t ues req RPC Client working client blocks time 5
  • 6. How RPC Generally Works  You write an application with a series of functions  One of these functions, F, will be distributed remotely  You call a “stub generator”  A caller stub emulates the function F:  Opens a connection to the server  Requests F, marshalling all parameters  Receives F’s return status and parameters  A server stub emulates the caller:  Receives a request for F with parameters  Unmarshals the parameters, invokes F  Takes F’s return status (e.g., protection fault), return value, and marshals it back to the client 6
  • 7. Passing Value Parameters  Steps involved in doing remote computation through RPC 2-8 7
  • 8. RPC Components  Generally, you need to write:  Your function, in a compatible language  An interface definition, analogous to a C header file, so other people can program for F without having its source  Generally, software will take the interface definition and generate the appropriate stubs (In the case of Java, RMIC knows enough about Java to run directly on the source file)  The server stubs will generally run in some type of daemon process on the server  Each function will need a globally unique name or GUID 8
  • 9. Parameter Passing Can Be Tricky Because of References  The situation when passing an object by reference or by value. 2-18 9
  • 10. What Are the Hard Problems with RPC? Esp. Inter-Language RPC?  Resolving different data formats between languages (e.g., Java vs. Fortran arrays)  Reliability, security  Finding remote procedures in the first place  Extensibility/maintainability  (Some of these might look familiar from when we talked about data exchange!) 10
  • 11. Web Services  Goal: provide an infrastructure for connecting components, building applications in a way similar to hyperlinks between data  It’s another distributed computing platform for the Web  Goal: Internet-scale, language-independent, upwards-compatible where possible  This one is based on many familiar concepts  Standard protocols: HTTP  Standard marshalling formats: XML-based, XML Schemas  All new data formats are XML-based 11
  • 12. Three Parts to Web Services 1. “Wire” / messaging protocols Data encodings, RPC calls or document passing, etc.  2. Describing what goes on the wire Schemas for the data  3. “Service discovery” Means of finding web services  12
  • 13. The Protocol Stacks of Web Services High-level WS-AtomicTransaction, Orchestration Other extensions state transition WS-Coordination (WS-BPEL) + msging WS-Addressing SOAP Attachments Message diagrams Sequencing between WS-Security Service Capabilities modules (WS-Capability) Service Description Directory SOAP, XML-RPC (WSDL) (UDDI) XML XML Schema Inspection Wire Format Stack Description Stack Discovery Stack Enhanced + expanded from a figure from IBM’s “Web Services Insider”, http://www-106.ibm.com/developerworks/webservices/library/ws-ref2/ 13
  • 14. Messaging Protocol: SOAP  Simple Object Access Protocol: XML-based format for passing parameters  Has a SOAP header and body inside an envelope  As a defined HTTP binding (POST with content-type of application/soap+xml)  A companion SOAP Attachments encapsulates other (MIME) data  The header defines information about processing: encoding, signatures, etc.  It’s extensible, and there’s a special attribute called mustUnderstand that is attached to elements that must be supported by the callee  The body defines the actual application-defined data 14
  • 15. A SOAP Envelope <SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://www.w3.org/2001/12/soap-envelope” xmlns:xsd=“http://www.w3.org/www.w3.org/2001/XMLSchema-instance”> <SOAP-ENV:Header> <t:Transaction xmlns:t=“www.mytrans.com” SOAP- ENV:mustUnderstand=“1” /> </SOAP-ENV:Header> <SOAP-ENV:Body> <m:PlaceOrder xmlns:m=“www.somewhere/there”> <orderno xsi:type=“xsd:string”>12</orderno> </m:PlaceOrder> </SOAP-ENV:Body> </SOAP-ENV: Envelope> 15
  • 16. Making a SOAP Call  To execute a call to service PlaceOrder: POST /PlaceOrder HTTP/1.1 Host: my.server.com Content-Type: application/soap+xml; charset=“utf-8” Content-Length: nnn <SOAP-ENV:Envelope> … </SOAP-ENV:Envelope> 16
  • 17. SOAP Return Values  If successful, the SOAP response will generally be another SOAP message with the return data values, much like the request  If failure, the contents of the SOAP envelop will generally be a Fault message, along the lines of: <SOAP-ENV:Body> <SOAP-ENV:Fault xmlns=“mynamespace”> <faultcode>SOAP-ENV:Client</faultcode> <faultstring>Could not parse message</faultstring> … 17
  • 18. How Do We Declare Functions?  WSDL is the interface definition language for web services  Defines notions of protocol bindings, ports, and services  Generally describes data types using XML Schema  In CORBA, this was called an IDL  In Java, the interface uses the same language as the Java code 18
  • 19. A WSDL Service Service Port Port Port PortType PortType PortType Operation Operation Operation Operation Operation Operation Binding Binding Binding 19
  • 20. Web Service Terminology  Service: the entire Web Service  Port: maps a set of port types to a transport binding (a protocol, frequently SOAP, COM, CORBA, …)  Port Type: abstract grouping of operations, i.e. a class  Operation: the type of operation – request/response, one-way  Input message and output message; maybe also fault message  Types: the XML Schema type definitions 20
  • 21. Example WSDL <service name=“POService”> <port binding=“my:POBinding”> <soap:address location=“http://yyy:9000/POSvc”/> </port> </service> <binding xmlns:my=“…” name=“POBinding”> <soap:binding style=“rpc” transport=“http://www.w3.org/2001/...” /> <operation name=“POrder”> <soap:operation soapAction=“POService/POBinding” style=“rpc” /> <input name=“POrder”> <soap:body use=“literal” … namespace=“POService” …/> </input> <output name=“POrderResult”> <soap:body use=“literal” … namespace=“POService” …/> </output> </operation> </binding> 21
  • 22. JAX-RPC: Java and Web Services  To write JAX-RPC web service “endpoint”, you need two parts:  An endpoint interface – this is basically like the IDL statement  An implementation class – your actual code public interface BookQuote extends java.rmi.Remote { public float getBookPrice(String isbn) throws java.rmi.RemoteException; } public class BookQuote_Impl_1 implements BookQuote { public float getBookPrice(String isbn) { return 3.22; } } 22
  • 23. Different Options for Calling  The conventional approach is to generate a stub, as in the RPC model described earlier  You can also dynamically generate the call to the remote interface, e.g., by looking up an interesting function to call  Finally, the “DII” (Dynamic Instance Invocation) method allows you to assemble the SOAP call on your own 23
  • 24. Creating a Java Web Service  A compiler called wscompile is used to generate your WSDL file and stubs  You need to start with a configuration file that says something about the service you’re building and the interfaces that you’re converting into Web Services 24
  • 25. Example Configuration File <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <configuration xmlns=quot;http://java.sun.com/xml/ns/jax- rpc/ri/configquot;> <service name=quot;StockQuotequot; targetNamespace=quot;http://example.com/stockquote.wsdlquot; typeNamespace=quot;http://example.com/stockquote/typesquot; packageName=quot;stockqtquot;> <interface name=quot;stockqt.StockQuoteProviderquot; servantName=quot;stockqt.StockQuoteServiceImplquot;/> </service> </configuration> 25
  • 26. Starting a WAR  The Web Service version of a Java JAR file is a Web Archive, WAR  There’s a tool called wsdeploy that generates WAR files  Generally this will automatically be called from a build tool such as Ant  Finally, you may need to add the WAR file to the appropriate location in Apache Tomcat (or WebSphere, etc.) and enable it  See http://java.sun.com/developer/technicalArticles/WebServices/WSPa for a detailed example 26
  • 27. Finding a Web Service  UDDI: Universal Description, Discovery, and Integration registry  Think of it as DNS for web services  It’s a replicated database, hosted by IBM, HP, SAP, MS  UDDI takes SOAP requests to add and query web service interface data 27
  • 28. What’s in UDDI White pages:  Information about business names, contact info, Web site name, etc. Yellow pages:  Types of businesses, locations, products  Includes predefined taxonomies for location, industry, etc. Green pages – what we probably care the most about:  How to interact with business services; business process definitions; etc  Pointer to WSDL file(s)  Unique ID for each service 28
  • 29. Data Types in UDDI  businessEntity: top-level structure describing info about the business  businessService: name and description of a service  bindingTemplate: how to access the service  tModel (t = type/technical): unique identifier for each service-template specification  publisherAssertion: describes relationship between businessEntities (e.g., department, division) 29
  • 30. Relationships between UDDI Structures publisherAssertion n 2 tModel businessEntity n 1 m n 1 n bindingTemplate businessService 30
  • 31. Example UDDI businessEntity <businessEntity businessKey=“0123…” xmlns=“urn:uddi-org:api_v2”> <discoveryURLs> <discoveryURL useType=“businessEntity”> http://uddi.ibm.com/registery/uddiget?businessKey=0123... </discoveryURL> <name>My Books</name> <description>Technical Book Wholesaler</description> … <businessServices> … </businessServices> <identifierBag> <!– keyedReferences to tModels  </identifierBag> <categoryBag> … </categoryBag> </businessEntity> 31
  • 32. UDDI in Perspective  Original idea was that it would just organize itself in a way that people could find anything they wanted  Today UDDI is basically a very simple catalog of services, which can be queried with standard APIs  It’s not clear that it really does what people really want: they want to find services “like Y” or “that do Z” 32
  • 33. The Problem: With UDDI and Plenty of Other Situations There’s no universal, unambiguous way of describing “what I mean”  Relational database idea of “normalization” doesn’t convert concepts into some normal form – it just helps us cluster our concepts in meaningful ways  “Knowledge representation” tries to encode definitions clearly – but even then, much is up to interpretation The best we can do: describe how things relate  pollo = chicken = poulet = 雞 = 鸡 = jī = मु ग ी = murg  Note that this mapping may be imprecise or situation-specific!  Calling someone a chicken, vs. a chicken that’s a bird 33
  • 34. This Brings Us Back to XQuery, Whose Main Role Is to Relate XML Suppose we define an XML schema for our target data and our source data A view is a stored query  Function from a set of (XML) sources to an XML output  In fact, in XQuery, a view is actually called a function Can directly translate between XML schemas or structures  Describes a relationship between two items  Transform 2 into 6 by “add 4” operation  Convert from S1 to S2 by applying the query described by view V Often, we don’t need to transfer all data – instead, we want to use the data at one source to help answer a query over another source… 34
  • 35. Lazy Evaluation: A Virtual View Browser/App Server(s) Source1.xml XQuery Virtual Query XQuery XML doc. Form Source2.xml Source1.xml XSLT Query Composed HTML Results XQuery Source2.xml 35
  • 36. Let’s Look at Some Simple Mappings  Beginning with examples of using XQuery to convert from one schema to another, e.g., to import data  First: let’s review what our XQuery mappings need to accomplish… 36
  • 37. Challenges of Mapping Schemas In a perfect world, it would be easy to match up items from one schema with another  Each element would have a simple correspondence to an element in the other schema  Every value would clearly map to a value in the other schema Real world: as with human languages, things don’t map clearly! Different decompositions into elements  Different structures  Tag name vs. value  Values may not exactly correspond  It may be unclear whether a value is the same  It’s a tough job, but often things can be mapped 37
  • 38. Example Schemas Bob’s Movie Database Mary’s Art List <movie> <workOfArt> <title>…</title> <id>…</id> <year>…</year> <type>…</type> <director>…</director> <artist>…</artist> <editor>…</editor> <subject>…</subject> <star>…</star>* <title>…</title> </movie>* </workOfArt>* Want to map data from one schema to the other 38
  • 39. Mapping Bob’s Movies  Mary’s Art Start with the schema of the output as a template: <workOfArt> <id>$i</id> <type>$y</type> <artist>$a</artist> <subject>$s</subject> <title>$t</title> </workOfArt> Then figure out where to find the values in the source, and create XPaths 39
  • 40. The Final Schema Mapping Mary’s Art  Bob’s Movies for $m in doc(“movie.xml”)//movie, $a in $m/director/text(), $i in $m/title/text(), $t in $m/title/text() return <workOfArt> <id>$i</id> <type>movie</type> Note the absence of subject… <artist>$a</artist> We had no reasonable source, <title>$t</title> so we are leaving it out. </workOfArt> 40

Notas del editor

  1. <number>