Demo Application
R. Alexander Milowski
milowski@sims.berkeley.edu
School of Information Management and Systems
#1
Application Architecture
Demo Architecture with Web Service
#3
Web Services
The simplest definition of a web service:
XML in
XML out
via a standard web protocol (e.g. http, https, etc.)
SOAP, WSDL, etc. are not required.
#4
Messages
Each message:
Asks the web service to do something as an XML document.
Has a single document as a response.
But that response document could have different content depending on the results.
This application has:
get event list - asks for the list of events.
create event - creates event(s).
delete event - deletes event(s).
alive - the response to a "ping" message.
error - notification of an error during the operation.
ok - notification of success
#5
Alive & HTTP GET
Just for kicks, I made the web service respond to a HTTP GET with no XML message.
It returns the alive message if successful:
<alive xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:webservice:event:200403"/>
#6
Get List Message
The request is simple:
<get-all-events xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:webservice:event:200403"/>
The response is a list of events:
<events xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:webservice:event:200403"> <event xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:schemas:event:200403" timestamp="1079122269643" start-date="sdfsdf" id="e1079122269651"> ... </event> </events>
#7
Create Event Message
The request is simple:
<add xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:webservice:event:200403"> <event xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:schemas:event:200403" timestamp="1079122269643" start-date="sdfsdf" id="e1079122269651"> ... </event> <event xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:schemas:event:200403" timestamp="1079122269643" start-date="sdfsdf" id="e1079122269651"> ... </event> </add>
The response the events repeated with the id value returned:
<ok xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:webservice:event:200403"> <event xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:schemas:event:200403" id="e1234" timestamp="1079122269643" start-date="sdfsdf" id="e1079122269651"> ... </event> <event xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:schemas:event:200403" id="e5678" timestamp="1079122269643" start-date="sdfsdf" id="e1079122269651"> ... </event> </ok>
#8
Delete Event Message
The request is simple:
<delete xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:webservice:event:200403"> <event ref="e1234"/> <event ref="e5678"/> </delete>
The response is a list of events:
<ok xmlns="urn:publicid:IDN+cde.berkeley.edu:examples:webservice:event:200403"/>
#9
Web Server Pipelines
Service-side Pipeline for Form Post
#10
Implementation
The web server uses Cocoon.
It uses a custom component that I wrote to post & receive the results from the web service.
The web service is a simple JSP page (242 lines) that runs in tomcat
The front-end (web service) XSLT is only 388 lines total.
The UI (web front end) is really, really basic (read: bad).
#11
Tomcat - J2EE Servlet Container
From the Apache website:
"Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed by Sun under the Java Community Process."
Simple description: Its a web server that runs servlets and JSP pages.
Available at Apache's Jakarta Project
#12
Cocoon
From the Cocoon website:
"Cocoon implements these concepts [separation of request from content & process] around the notion of 'component pipelines', each component on the pipeline specializing on a particular operation. This makes it possible to use a Lego(tm)-like approach in building web solutions, hooking together components into pipelines without any required programming."
Basically, you map URL requests to pipelines.
Pipelines can do simple or complex "inline" processes.
Available at Apache's Cocoon Website
#13
Three Pipelines
This application uses three pipelines:
Handle post data & talk to the web service.
Handle get queries & talk to the web service.
Style XML content with XSLT.
#14
JSP for Web Service
A web service can be written in any language.
This demo uses JSP for simplicity.
The JSP page consumes XML and produces an XML page.
It looks like any other JSP page except my XML elements are used instead of XHTML.
It would be much nicer to have it call a real "library of Java code".