Title: Web Services in Perl
1Web Services in Perl .NET
2But First
3What 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
4The March of Technology
- Sockets
- Remote Procedure Calls (RPC)
- COM/DCOM, CORBA, Java/RMI
- HTTP
- XML
- SOAP
- Web Services
5Sockets
- 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
6Remote 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
7COM/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
8HTTP
- 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 !
9XML
- 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 !
10Convergence !
- 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
11What 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 !
12Distributed 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
13SOAP
- 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
14SOAP 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
15A 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
16Simple 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
17Temperature 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
-
18A 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
19A 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
20What 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
21Programming Web Serviceswith Perl
- Randy Ray Pavel Kulchenko
- OReilly, 2003
- 437 pages
- 39.95, discounted to 27.97 on Amazon
- 5 stars, 5 reviews
22Programming Microsoft .NET
- Jeff Prosise
- Microsoft Press, 2002
- 773 pages
- 59.99, discounted to 41.99 on Amazon
- 4.5 stars, 19 reviews
23Web 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)
24The Last Word