Cocoon: A Framework for Web Services - PowerPoint PPT Presentation

About This Presentation
Title:

Cocoon: A Framework for Web Services

Description:

Cocoon: A Framework for Web Services Using Cocoon to consume and produce Web Services Pankaj Kumar pankaj_kumar_at_hp.com Web Services Architect, HP Middleware – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 33
Provided by: Pankaj57
Category:

less

Transcript and Presenter's Notes

Title: Cocoon: A Framework for Web Services


1
Cocoon A Framework for Web Services
  • Using Cocoon to consume and produce Web Services

Pankaj Kumar pankaj_kumar_at_hp.com Web Services
Architect, HP Middleware
2
Presentation Goals
  • Understand Apache Cocoon, Web Services and how
    Cocoon can be used to build
  • Web Applications that consume Web Services and
  • Web Services that process huge XML documents

3
Speakers Qualifications
  • More than 12 years of System Programming
    experience
  • Development manager in HP E-speak development
  • Development manager of HP XML Application
    Frameworks ( Cocoon connection )
  • Currently Web Services Architect at HP Middleware
    ( Web Services connection )
  • Contributor to Cocoon project
  • JAX-RPC and JSR109 Expert Group Member
  • Personal web-site http//www.pankaj-k.net

4
Presentation Topics
  • What is Cocoon?
  • Exploring Cocoon
  • What are Web Services?
  • Cocoon and Web Services
  • A Simple Cocoon Web Application

5
What is Cocoon?
6
Apache Cocoon
  • XML based publishing Framework
  • An Apache Software Foundation opensource project
  • Written in Java, runs as a servlet ( not strictly
    true ! )
  • Project Home Page http//xml.apache.org/cocoon
  • Started as a simple servlet based XSL styling
    engine for http//java.apache.org site
  • Current version is in the second generation of
    evolution
  • Designed for scalability ( uses SAX processing )
    -- can process huge documents using small amount
    of memory

7
Apache Cocoon ( Contd. )
  • Promotes separation of Content, Logic,
    Presentation and Management in web-site design.

8
Exploring Cocoon
9
Getting Started
  • Download Cocoon Distribution from
    http//xml.apache.org/cocoon
  • I used Cocoon 2.0.1 for this presentation
  • Unzip the distribution file cocoon-2.0.1-bin.zip.
  • Drop cocoon.war to webapps directory of your
    Servlet Container
  • I used Tomcat 4.0.1 as the Servlet Container
  • Start the Servlet Container
  • Point your browser to http//localhost8080/cocoon

10
Cocoon Welcome Page
11
Cocoon Servlet Dirs. Files
Directory for auto mounting sub-sitemaps
Cocoon Configuration file
A sub-sitemap directory
Main sitemap file
Directory for log files
12
Cocoon Sitemap
  • Why Sitemap ?
  • need to de-couple exposed URI space from actual
    location of resources
  • need easily changeable specification of
    processing steps
  • What does it contain?
  • Component declarations
  • generators, transformers, serializers, ...
  • Resource declarations
  • named collection of pipeline components
  • Pipeline declarations
  • sequential arrangement of components for
    processing

13
Cocoon Sitemap ( Contd. )
  • A sitemap is an XML file
  • Sitemaps are hierarchical -- A sitemap can point,
    explicitly or implicitly, to sub-sitemaps
  • A sitemap is translated into a java program and
    is compiled to bytecode
  • Changes to sitemaps can be loaded dynamically and
    asynchronously.
  • Cocoon community has debated extensively on
    philosophical aspects of Sitemap but nothing
    better has come out ( yet ! ).

14
A sample pipeline
  • ltmappipelinegt
  • ltmapmatch pattern"hello.html"gt
  • ltmapgenerate src"docs/samples/hello-page.xml
    "/gt
  • ltmaptransform src"stylesheets/page/simple-pa
    ge2html.xsl"/gt
  • ltmapserialize type"html"/gt
  • lt/mapmatchgt
  • ltmapmatch pattern"images/.png"gt
  • ltmapread src"resources/images/1.png"
    mime-type"image/png"/gt
  • lt/mapmatchgt
  • ltmaphandle-errorsgt
  • ltmaptransform src"context//stylesheets/syst
    em/error2html.xsl"/gt
  • ltmapserialize status-code"500"/gt
  • lt/maphandle-errorsgt
  • lt/mappipelinegt

15
Request Processing By Cocoon
  • Request is dispatched to matching pipeline
  • Basic pipeline operation
  • The generator generates XML content
  • Zero or more transformers transform the content
  • The serializer writes it to the output stream
  • Different Kinds of generators
  • File, Directory, XSP, JSP, Stream,
  • Different Kinds of transformers
  • XSLT, I18N, Log,
  • Different Kind of Serializers
  • HTML, XML, Text, PDF, SVG, ...

16
Dynamic Content from XSP
  • lt!-- A simple XSP Page --gt
  • ltxsppage language"java
  • xmlnsxsphttp//apache.org/xsp gt
  • ltpagegt
  • lttitlegtA Simple XSP Pagelt/titlegt
  • ltcontentgt
  • ltparagtdynamically generated listlt/paragt
  • ltulgt
  • ltxsplogicgt
  • for (int i0 i lt 3 i)
  • ltligt Item
  • ltxspexprgtilt/xspexprgt
  • lt/ligt
  • lt/xsplogicgt
  • lt/ulgt
  • lt/contentgt
  • lt/pagegt
  • lt/xsppagegt

17
What Are Web Services?
18
Defining Web Services
  • Most commonly used definition
  • Web Services are
  • described in WSDL
  • exchange SOAP messages
  • use HTTP as transport
  • optionally, registered in UDDI registry
  • Interaction can happen using RPC style or
    Document Exchange style, synchronously or
    asynchronously
  • Knowledge of Implementation language or
    deployment platform is not required for
    interaction.
  • Web Services promise Interoperability.

19
SOAP 1.1
  • XML based protocol for exchange of information
  • Encoding rules for datatype instances
  • Convention for representing RPC invocations
  • Designed for loosely-coupled distributed
    computing
  • Used with XML Schema
  • Transport independent
  • SOAP with Attachments allow arbitrary data to be
    packaged.

20
WSDL 1.1
WSDL 1.1 Document Structure
  • A WSDL document describes
  • What the service can do
  • Where it resides
  • How to invoke it
  • WSDL are like IDL but lot more flexible and
    extensible
  • Defines binding for SOAP1.1, HTTP GET/POST and
    MIME
  • WSDL descriptions can be made available from an
    UDDI registry

WSDL Document
Types
Messages
PortTypes
Bindings
Services
21
What is a Web Services Platform ?
  • Environment, tools, libraries and other resources
    for
  • Development of web services
  • top down -- start with user code and generate
    WSDL
  • bottom up -- start with WSDL and generate
    interfaces
  • middle out -- a combination
  • discovery of service interfaces
  • Deployment of web services
  • publishing of services
  • pre and post processing of SOAP requests,
    responses
  • processing requests for WSDL descriptions
  • Consumption of Web Services
  • discovery of Web Service
  • invocation of/interaction with Web Services

22
Java Platforms and Standards
  • Java Platforms for Web Services
  • HP WSP, HP WSR, HP WST
  • Apache SOAP 2.2, Apache Axis, UDDI4J, Cocoon
  • JWSDK ( Reference Implementation from Sun )
  • Emerging Java Standards for Web Services
  • JAXM ( Java XML Messaging )
  • JAX-RPC ( Java Web Service Client Prog. model)
  • JSR 109 ( Java Web Service Prog. Model,
    deployment, ...)
  • JAXR ( Java API to access Web Service Registries
    )
  • J2EE 1.4 ( J2EE platform for Web Services )
  • Java standards promise portability

23
Observations on Java Platforms and Standards
  • Handle synchronous RPC style Web Services quite
    well
  • Not so good at supporting Web Services with
    document exchange style, especially with
    asynchronous interface
  • Have difficulty dealing with large data
  • Many approaches to build and consume Web Services
    ( but must adhere to wire protocols )
  • Standards in many areas are still emerging
  • routing, reliable messaging
  • security
  • transactioning
  • ...

24
Cocoon and Web Services
25
Cocoon as a Presentation Framework for
Web-Services
26
Cocoon as a Processing Framework for Web Services
27
A Simple Cocoon Web Application
28
Problem Statement
  • Use Google Web Services API from
    http//www.google.com/apis
  • to create a simple web application that accepts a
    search string from user and displays the list of
    result entries.
  • Acknowledgement This example is based on the XSP
    contributed by Ugo Cei in Cocoon-dev mailing
    list.

29
Application Components
  • sitemap.xmap -- Sitemap for this application
  • index.html -- HTML file to accept search string
  • google.xsp -- XSP file that makes the SOAP call
    to Google Web Service using SOAP logicsheet.
  • search-results.xsl -- XSL stylesheet to transform
    SOAP response from Google Web Service to HTML
    page
  • Downloadable from
  • http//www.pankaj-k.net/sdwest2002/google.zip

30
Application Architecture
Google WS
Cocoon Servlet
Browser
http//lthostgt/cocoon/mount/google/
Maps request to index.html
index.html
/search?q...
SOAP request
SOAP response
executes google.xsp
Search results in HTML
Applies search-results.xsl
31
Demo Architecture
Cocoon Servlet
Browser
http//lthostgt/cocoon/mount/google/welcome-local
Maps request to index-local.html
index.html
/search-local?q...
Reads google.results
Search results in HTML
Applies search-results.xsl
32
Web Application Demo
  • Walk through the
  • Design, Sources
  • and the Demo
Write a Comment
User Comments (0)
About PowerShow.com