Copyright 1995 Architecture Projects Management LimitedThe copyright is held on behalf of the sponsors for the time being of the ANSA Workprogramme.
Poseidon HouseCastle ParkCambridge CB3 0RDUnited Kingdom
TELEPHONE: Cambridge (01223) 515010INTERNATIONAL: +44 1223 515010
FAX: +44 1223 359779E-MAIL: [email protected]
ANSA Phase III
Distribution:
Supersedes :
Superseded by :
APM.1494.01 Approved 23rd May 1995
External Paper
Object Wrapping for the WWW
Nigel Edwards
Abstract
This is a presentation of the ANSA web programming kit also described in reports APM.1465 andAPM.1464.
Deploying new and customised applications and services in the internet is difficult. Yet manyorganisations require more than the basic functionality provided by standard applications such asHTTP servers (WWW servers).
The tool kit described in this document demonstrates how it can be made relatively easy toprogram applications in WWW which use libwww and, in particular, CGI and HTTP. By using theconcept of client and server stubs we have provided a layer of abstraction which protects theprogrammer from the underlying details of the protocols. This means that programmers have lesswork to do to write their applications and because they have less code to write, they are less likelyto make mistakes.
Currently we have written only a very few applications using the kit; the presentation describesone application in which it is used to study and measure the performance of HTTP servers.
123rd May 1995Approved External PaperAPM.1494.01
Object Wrapping for the WWW
Nigel Edwards
223rd May 1995Approved External PaperAPM.1494.01
Introduction
• Some example applications — why do you need to program the web?
• What problems are faced by web programmers?
• How distributed objects can help
• The ANSA web programming kit
323rd May 1995Approved External PaperAPM.1494.01
A “commercial” application
User interface: a web browser(e.g. Mosaic) using html forms
HTTP
Document storecontaining programinformation
www.covent.garden.com
• Scenario: booking theatretickets for multiple events.
• Requirements- Browsing program
information- Choice of seats & dates- On-line selection of
preferences- Confirmation of booking by
server- Ability to change booking- Single payment on
confirmation of booking byclient
423rd May 1995Approved External PaperAPM.1494.01
Extending the functionality of WWW using CGI Programs
www.covent.garden.com
Bookingdatabase(legacy system)
state storefor CGI programs(local file system)
reserve|cancel|payment| commit|.............
User interface: a web browser(e.g. Mosaic) using html forms
HTTP
CGI
Enter arguments here:Some ArgumentAnother argument:And another:e.g. credit card no.:
To invoke the operation:
MosaicLots of text goes here to tell the customer what to do.What follows are input fields which allow customer tosupply parameters to the operation which is about to beinvoked...................................................... .................... ................. .....
book
default
****
default value
default
523rd May 1995Approved External PaperAPM.1494.01
OSF-RI OreoMosaic
ANSA is an architecturefor distributed computersystems. Its objective is toenable application compo-nents to work together de-spite diversity andevolution of programming
MosaicANSA is an architecturefor distributed computersystems. Its objective is toenable application compo-nents to work together de-spite diversity andevolution of programming
MosaicANSA is an architecturefor distributed computersystems. Its objective is toenable application compo-nents to work together de-spite diversity andevolution of programming
http://plato.ansa.co.uk/local/
http://www.pipex.nethttp://www.cl.cam.ac.uk http://plato.ansa.co.uk/ansa.html
http://plato.ansa.co.uk/Staff/index.html
http://plato.ansa.co.uk/Staff/ajh.htmll
http://really.cool.coml
http://mega.cool.coml
Proxy, creating a map showing where co-workers have been in the web
Proxy, creating searchable index ofretrieved pages
HTTP Request forwarded totarget server
Web Map
See also: WebMail ProjectFor more details: <URL:http://web1.osf.org:8001/www/>
623rd May 1995Approved External PaperAPM.1494.01
WWW is being used to create a uniform “Information Space”
This requires technology for :
• Presentation (= Browsers + HTML, postscript etc.)
• Creation (= Authoring tools)
• Integration (= CGI)
• Administration (= ?????)
Well understood
Poorly understood
Programming tools are needed to make it easier tobuild these applications.
723rd May 1995Approved External PaperAPM.1494.01
Programming in the Web without tools
State storefor CGI programs(local file system)
Enter arguments here:
Some Argument
Another argument:
And another:
e.g. credit card no.:
MosaicLots of text goes here to tell the customer
what to do. What follows are input fields
which allow customer to supply ............
book
default
****
default value
default
libwww
Application
HTTP ServerHTTP
HTTPHTTP
CGI
CGI
IntegratedInformationService
CGIPrograms
Browser withHTML Form
(HTML)document store
823rd May 1995Approved External PaperAPM.1494.01
Notes on the previous slide — not for presentation- Currently server/browser interaction uses HTTP (HyperText Transfer Protocol) — an RPC protocol.
- The CGI (Common Gateway Interface) protocol running over (unix) pipes allows HTTP servers to communicatewith other programs.
- This allows service providers to extend the functionality of their web servers (in ANSA we used it to provide aweb interface to the trader).
- It is hard (error prone) to write the code to unmarshal the parameters to the CGI programs (no tool support).
- A CGI Program gets “forked” each time it is invoked, so state has to be stored externally.
- CGI programs are driven by HTML (HyperText Mark-up Language) forms technology. HTML forms are activedocuments: browsers marshal the parameters provided by the user and (using HTTP) passes them to the HTTPserver. In turn, the HTTP server passes them to the CGI program.
- Care is needed to make sure the HTML form and corresponding CGI program are consistent (both in numbersand “types” of parameters).
- Customisation is limited by what can be displayed in browsers using HTML forms technology
- Implementing a custom client requires programming on libwww. This is very difficult to do: libwww presents acomplex API and is subject to change; programmers require a deep understanding of protocol details (HTTP)as well as the internals of the library
923rd May 1995Approved External PaperAPM.1494.01
The Solution: Distributed Object Technology
ClientsServiceinterface
Management interface
Legacy or integratedapplications
Encapsulating object
Gatewayobject
client application
IDL stub
platform
Platform
IDL Skeleton
1023rd May 1995Approved External PaperAPM.1494.01
Notes on the previous slide — not for presentation- CORBA’s (or distributed object technology) key value proposition is that it makes writing management and
integration applications easy.
- The key idea is to access services through defined (in IDL) interfaces
- From the descriptions of the services we want to access, stub compilers can generate IDL stubs and skeletonswhich abstracts the programmer from the underlying protocols and API.
- Invocation of a remote service becomes very like iocal procedure call; it is no longer necessary to have a deepunderstanding of the underlying protocols or the internals of the platform.
1123rd May 1995Approved External PaperAPM.1494.01
A Stub Compiler for the web
CGI program
IDL stublibwww
Bespoke client
Generate IDLskeletons for serversGenerate
IDL stubs for clients
IDL for Service
GenerateForm (on the fly)
HTTP Server
Browser
IDLSkeleton
Application
1223rd May 1995Approved External PaperAPM.1494.01
CORBA IDL describes the CGI serviceinterface Echo{ string Echo(in string Src); void Sink(in string Src); string Source(in long Length); string Reverse(in string Src);};
interface simple3 : simple2 { exception OVERFLOW {
long a;string msg;
}; long op4(in long x, inout long y, out long z) raises(OVERFLOW);};
1323rd May 1995Approved External PaperAPM.1494.01
A client program and protocol stack#include <CEcho.h>PUBLIC char * HTAppName = “Echo client”; /* Application name */PUBLIC char * HTAppVersion = “0”; /* Application version */CORBA_string obuf;char ibuf[1024];
int main(int argc, char* argv[]){ CORBA_Environment ev = {CORBA_NO_EXCEPTION, 0, 0}; Echo ref = NULL; int n;
ref = Stub_bind(“http://outlaw.ansa.co.uk:8000/cgi-bin/Echo”, &ev); handle(&ev); printf(“Ctrl-D to end the input loop\n”); printf(“> “); fflush(stdout); while(n = read(0, (void *) ibuf, sizeof(ibuf))) {
ibuf[n] = ‘\0’;obuf = Echo_Echo(ref, &ev, ibuf);
handle(&ev); printf(“%s”, obuf); Stub_free(obuf); printf(“> “); fflush(stdout);
}HTAnchor_delete(ref);
}
Name and version ofthe application
Convert the URL to auseable reference
Exception handling
Remote operationinvocation
Garbage collectthe reference
TCP/IP
client.c
IDL Stub
libwww
Stub library
1423rd May 1995Approved External PaperAPM.1494.01
The server program and protocol stack#include <SEcho.h>PUBLIC char * HTAppName = “Echo server”; /* Application name */PUBLIC char * HTAppVersion = “0”; /* Application version */
static char buffer[32000];
CORBA_string Echo_Echo(CORBA_Environment *ev, CORBA_string Src){if (stub_browser) printf(“Echo::\n%s”, Src);
return Src;}
/*Echo_Source and Echo_Sink deleted*/
CORBA_string Echo_Reverse(CORBA_Environment *ev, CORBA_string Src){register char *sp;
int n;
for (sp = buffer, n = strlen(Src) - 1; n >= 0; n--) *sp++ = Src[n]; *sp = ‘\0’;
if(stub_browser) printf(“Result of Echo_Reverse\n%s”, buffer);return buffer;}
TCP/IP
Echo.c
IDL Skeleton
HTTP Server
Stub library
CGI
Distinguish between browsers& other application invocations
1523rd May 1995Approved External PaperAPM.1494.01
HTML Form Clients
• HTML forms generated from the IDL
• Subset of CORBA IDL typessupported
• Forms are templates, edit to:- Adjust input field size- Add explanatory text
• Generated forms are syntacticallycorrect HTML
1623rd May 1995Approved External PaperAPM.1494.01
HTML Form Generation
interface Echo{ string Echo(in string Src); void Sink(in string Src); string Source(in long Length); string Reverse(in string Src);};
<head><TITLE>Input for Echo</TITLE></head><BODY><H1>Input for Echo</H1><HR>
<H2> Operation Echo</H2><FORM METHOD=”POST” ACTION=”http://socrates.ansa.co.uk:8080/cgi-bin/Echo”><P>Enter arguments here:<P><INPUT NAME=”Operation” TYPE=hidden VALUE=”Echo_Echo”>CORBA_string Src: <INPUT SIZE=10 NAME=”Src”> <P>To invoke Echo_Echo: <INPUT TYPE=”submit” VALUE=”Echo_Echo”><P></FORM><HR>
<H2> Operation Sink</H2><FORM METHOD=”POST” ACTION=”http://socrates.ansa.co.uk:8080/cgi-bin/Echo”><P>Enter arguments here:<P><INPUT NAME=”Operation” TYPE=hidden VALUE=”Echo_Sink”>CORBA_string Src: <INPUT SIZE=10 NAME=”Src”> <P>To invoke Echo_Sink: <INPUT TYPE=”submit” VALUE=”Echo_Sink”><P></FORM><HR>
<H2> Operation Source</H2><FORM METHOD=”POST” ACTION=”http://socrates.ansa.co.uk:8080/cgi-bin/Echo”><P>Enter arguments here:<P><INPUT NAME=”Operation” TYPE=hidden VALUE=”Echo_Source”>CORBA_long Length: <INPUT SIZE=10 NAME=”Length”> <P>To invoke Echo_Source: <INPUT TYPE=”submit” VALUE=”Echo_Source”><P></FORM><HR>
<H2> Operation Reverse</H2><FORM METHOD=”POST” ACTION=”http://socrates.ansa.co.uk:8080/cgi-bin/Echo”><P>Enter arguments here:<P><INPUT NAME=”Operation” TYPE=hidden VALUE=”Echo_Reverse”>CORBA_string Src: <INPUT SIZE=10 NAME=”Src”> <P>To invoke Echo_Reverse: <INPUT TYPE=”submit” VALUE=”Echo_Reverse”><P></FORM></BODY>
Stub Compiler generates this HTML form
Don’t try to read this
1723rd May 1995Approved External PaperAPM.1494.01
Example application — performance measurement
• Echo client takes 215 msecs/invocation on lightly loaded PA-RISC
• Process fork & reading back from a pipe only takes 9-10 msecs
• Where is the missing 195 msecs — CPU bound?
• Implies threads alone will not give high performance
libwww
Echo client
HTTP ServerForks a copy of itselfto handle the request
CGI program
CGI
HTTP
Echo
(forked)HTTP Server
1823rd May 1995Approved External PaperAPM.1494.01
Current status
• Some limitations- CORBA Type “Any” not supported- Stateless servers and no threads- “Interfaces” are URLs so no location transparency or
relocation
• Size of sources (not including .hh, .h and .idl files):- Back-end 6000 lines of C++- Stub library 2300 lines of C
• Applications are written in C
Need a better execution model
1923rd May 1995Approved External PaperAPM.1494.01
Availability• Available via ftp to sponsors only at present
• APM.1465.00.02 “A Stub Compiler for CGI and HTTP: TheProgrammer’s Guide” 32pp, Technical Report- Architecture details and code examples- More limited test applications bundled with the software
• APM.1464.01 “Object Wrapping (for WWW) - The Key to IntegratedServices?” 7pp, External paper- The overview paper- Also available as
<URL:http://www.ansa.co.uk/phase3-activities/1464/1464prt1.html>
2023rd May 1995Approved External PaperAPM.1494.01
Conclusions• So far only limited application experience — need more
- So this should be regarded as “the first cut”- Performance measurements would have been difficult without the
toolkit
• The toolkit makes programming the web easy by abstracting from theunderlying protocols and libraries (libwww)
• How the ANSA work fits together:- A programming model and kit for the web/internet- Changeling: how to deploy new programs and upgrade existing ones- Meta-Information: how to find resources- Re-engineering the infrastructure will give the scalability and
performance required by the above