Web Services in Perl

1 / 24
About This Presentation
Title:

Web Services in Perl

Description:

Fine-grained naming and locating. Simple, extensible data encoding. Simple, extensible metadata ... don't have to deal with locating the service you need. March ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 25
Provided by: johnz68

less

Transcript and Presenter's Notes

Title: Web Services in Perl


1
Web Services in Perl .NET
  • John Zugel
  • March 2004

2
But First
3
What Problem Are We Solving ?
  • How can we distribute computing ?
  • Granularity client/server vs function calls
  • Naming and describing things
  • Data encoding, transfer, decoding
  • Finding and locating things
  • Cross-platform, multi-language
  • Transparency
  • Security
  • Fault, error, exception handling

4
The March of Technology
  • Sockets
  • Remote Procedure Calls (RPC)
  • COM/DCOM, CORBA, Java/RMI
  • HTTP
  • XML
  • SOAP
  • Web Services

5
Sockets
  • Peer-to-peer disguised as client-server
  • Abstracted to IP address port
  • Protocols datagram or stream
  • Higher-level protocol left to user
  • Byte-ordering
  • Values vs references
  • Locating peers
  • Describing services

6
Remote Procedure Calls (RPC)
  • Looks like a normal procedure call
  • Hides network code in stub
  • Simple types supported
  • User-defined types possible
  • By-reference simulated by copy/restore
  • IDL makes coding easier
  • Location, security, call semantics DIY

7
COM/DCOM, CORBA, Java/RMI
  • Objects
  • Heavyweight solutions
  • Work best if you stay within the family
  • Objects located by registry or repository
  • Allows arbitrary data structures
  • Exception handling
  • Multiple-language support, kind of
  • IDL and type information

8
HTTP
  • Request-response protocol
  • Header-body separation
  • URLs / URIs as names and locators
  • Textual content and MIME types
  • CGI / ASP / PHP dynamic services
  • Security and exception handling
  • Not a distributed computing solution
  • Ubiquitous !

9
XML
  • Describes data IAW DTD or Schema
  • Text-based
  • Any/all data can be described
  • Real data simple and complex types
  • Fault, error, exception data
  • Routing, naming/locating data
  • DIY unless someone else already did it
  • Ubiquitous !

10
Convergence !
  • Server as container
  • Fine-grained naming and locating
  • Simple, extensible data encoding
  • Simple, extensible metadata
  • Transparent, cross-platform, multi-language
  • Fine-grained services
  • Security directory issues remain

11
What is a Web Service ?
  • Software component
  • Platform implementation-independent
  • Invoked thru a declared API
  • Described by a service description
  • Published in a registry of services
  • Can be composed with other services
  • Discovered by a standard mechanism
  • Ubiquitous !

12
Distributed Computing, Redux
  • XML-RPC
  • SOAP Simple Object Access Protocol
  • WSDL Web Service Description Language
  • UDDI Universal Description, Discovery and
    Integration (also DISCO and WSIL)
  • But theres also ebXML and BPEL as alternative
    web services directions

13
SOAP
  • Builds on RPC, HTTP, XML
  • A message has an envelope, header (optional), and
    a body
  • Used for both RPC and documents
  • Security, authentications, transactions, and
    other requirements can be met by layering via
    actors and nodes
  • mustUnderstand

14
SOAP Message Parts
  • Envelope holds namespace URIs for versioning and
    encoding,
  • Header provides OOB data (optional)
  • Authentication security
  • Routing, transactions, etc
  • Error and handling instructions
  • Body provides encoded data for final message
    recipient

15
A SOAP Message
  • ltSOAP-ENVEnvelope xmlnsSOAP-ENVhttp//schemas.
    xmlsoap.org/soap/envelopegt
  • ltSOAP-ENVHeadergt
  • ltauthAuthorize xmlnsauthgt
  • ltauthtypegtuserlt/authtypegt
  • ltauthnamegtJoeUserlt/auth name gt
  • lt/SOAP-ENVHeadergt
  • ltSOAP-ENVBodygt
  • ltcallgetQuote xmlnscallgt
  • more stuff about the quote, perhaps
  • lt/SOAP-ENVBodygt
  • lt/SOAP-ENVEnvelopegt

16
Simple Temperature Service
  • Shamelessly stolen from xmethods.com
  • See Xmethods Demo Services
  • Implemented in Perl and .NET (C)
  • Defines one operation getTemp ()
  • Takes a string containing zipcode
  • Returns a float containing temperature
  • Monitored with Ethereal

17
Temperature Service WSDL
  • lt?xml version"1.0" ?gt
  • ltdefinitions name"TemperatureService"
  • targetNamespace"http//www.xmethods.
    net/sd/TemperatureService.wsdl"
  • xmlnstns"http//www.xmethods.net/sd
    /TemperatureService.wsdl"
  • xmlnsxsd"http//www.w3.org/2001/XML
    Schema"
  • xmlnssoap"http//schemas.xmlsoap.or
    g/wsdl/soap/"
  • xmlns"http//schemas.xmlsoap.org/wsd
    l/"gt
  • ltmessage name"getTempRequest"gt ltpart
    name"zipcode" type"xsdstring" /gt lt/messagegt
  • ltmessage name"getTempResponse"gt ltpart
    name"return" type"xsdfloat" /gt lt/messagegt
  • ltportType name"TemperaturePortType"gt
  • ltoperation name"getTemp"gt
  • ltinput message"tnsgetTempRequest" /gt
  • ltoutput message"tnsgetTempResponse" /gt
  • lt/operationgt
  • lt/portTypegt

18
A Simple Web Service in Perl
  • use SOAPLite
  • zipcode shift
  • print SOAPLite
  • -gtservice("http//www.xmethods.net/sd/2001/T
    emperatureService.wsdl")
  • -gtgetTemp(zipcode)
  • Invoked by perl GetTemp.pl 95133
  • The SOAPLite toolkit does all the heavy lifting

19
A Simple Web Service in .NET
  • // TemperatureService is the proxy to the web
    service.
  • // First, instantiate the proxy
  • TemperatureService tempSvc new
    TemperatureService( )
  • // Next, call the service via the proxy
  • Single result tempSvc.getTemp(
    zipCodeEntry.Text )
  • wsdl.exe generates the proxy class
  • Visual Studio .NET does all the work

20
What was the point of all this ?
  • Web services look like objects
  • Web services are easy
  • If you dont have to deal with the XML
  • If you dont have to deal with connectivity
  • If you dont have to deal with locating the
    service you need

21
Programming Web Serviceswith Perl
  • Randy Ray Pavel Kulchenko
  • OReilly, 2003
  • 437 pages
  • 39.95, discounted to 27.97 on Amazon
  • 5 stars, 5 reviews

22
Programming Microsoft .NET
  • Jeff Prosise
  • Microsoft Press, 2002
  • 773 pages
  • 59.99, discounted to 41.99 on Amazon
  • 4.5 stars, 19 reviews

23
Web Resources
  • World Wide Web Consortium (w3.org)
  • SOAPLite Perl toolkit (soaplite.com)
  • Cygwin Unix-on-Win32 (cygwin.com)
  • CPAN for Perl (cpan.org)
  • ActiveState Perl (activestate.com)
  • Microsoft .NET Framework SDK (msdn.microsoft.com)
  • Publicly available web services (xmethods.net)

24
The Last Word
Write a Comment
User Comments (0)