Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cocoon: A Framework for Web Services

Similar presentations


Presentation on theme: "Cocoon: A Framework for Web Services"— Presentation transcript:

1 Cocoon: A Framework for Web Services
9/18/2018 Cocoon: A Framework for Web Services Using Cocoon to consume and produce Web Services Pankaj Kumar Web Services Architect, HP Middleware Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

2 9/18/2018 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 Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

3 Speakers’ Qualifications
9/18/2018 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: Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

4 Presentation Topics What is Cocoon? Exploring Cocoon
9/18/2018 Presentation Topics What is Cocoon? Exploring Cocoon What are Web Services? Cocoon and Web Services A Simple Cocoon Web Application Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

5 9/18/2018 What is Cocoon? Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

6 Apache Cocoon XML based publishing Framework
9/18/2018 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: Started as a simple servlet based XSL styling engine for 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 History: Cocoon Project was started by Stefano Mazzocchi in 1998. Reference: An article by Stefano on Cocoon Running Cocoon: Cocoon can also be run as a standalone program taking commandline arguments; or Main Cocoon class can be instantiated from another Java program. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

7 9/18/2018 Apache Cocoon ( Contd. ) Promotes separation of Content, Logic, Presentation and Management in web-site design. Four different working contexts (the rectangles): Management - The people that decide what the site should contain, how it should behave and how it should appear Content - The people responsible for writing, owning and managing the site content. This context may contain several sub-contexts - one for each language used to express page content. Logic - The people responsible for integration with dynamic content generation technologies and database systems. Style - The people responsible for information presentation, look & feel, site graphics and its maintenance. Five contracts (the lines) management - content management - logic management - style content - logic content - style Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

8 9/18/2018 Exploring Cocoon Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

9 9/18/2018 Getting Started Download Cocoon Distribution from I used Cocoon for this presentation Unzip the distribution file cocoon bin.zip. Drop cocoon.war to webapps directory of your Servlet Container I used Tomcat as the Servlet Container Start the Servlet Container Point your browser to Preconditions -- You need a Web Browser, Java SDK and a Servlet container on your machine and sufficient disk space. I used: -- Windows 2000 machine -- IE 5.0 -- JDK from Sun Microsystems -- Apache Tomcat 4.0.1 Directory Structure -- unzipping the distribution file creates directory cocoon with subdirectories docs, legal and WAR file cocoon.war. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

10 9/18/2018 Cocoon Welcome Page This page is also the entry point for all bundled samples and examples. A good way to find out various features is to play around with this page. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

11 Cocoon Servlet Dirs. & Files Directory for auto mounting sub-sitemaps
9/18/2018 Cocoon Servlet Dirs. & Files Directory for auto mounting sub-sitemaps Cocoon Configuration file A sub-sitemap directory Sitemaps are hierarchical. A sub-sitemap can be dynamically added, without modifying the parent sitemap, by moving to directory for auto mounting. A number of logs are maintained in the WEB-INF\log directory. Very useful for debugging. log-level is specified in file web.xml of Cocoon servlet. Main sitemap file Directory for log files Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

12 Cocoon Sitemap Why Sitemap ? What does it contain?
9/18/2018 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 Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

13 Cocoon Sitemap ( Contd. )
9/18/2018 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 ! ). Dynamic loading of sitemap ==> no need to stop and start the Cocoon servlet for changes in the sitemap to become effective. Asynchronous loading of sitemap ==> The sitemap is read, validated, compiled and loaded in the background, without impacting the response time of the system during this process. Sitemap Critique: Sitemap mixes control ( logic ) and management. Single point of failure. Hard to maintain. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

14 A sample pipeline <map:pipeline>
9/18/2018 A sample pipeline <map:pipeline> <map:match pattern="hello.html"> <map:generate src="docs/samples/hello-page.xml"/> <map:transform src="stylesheets/page/simple-page2html.xsl"/> <map:serialize type="html"/> </map:match> <map:match pattern="images/**.png"> <map:read src="resources/images/{1}.png" mime-type="image/png"/> <map:handle-errors> <map:transform src="context://stylesheets/system/error2html.xsl"/> <map:serialize status-code="500"/> </map:handle-errors> </map:pipeline> Processing of XML within a pipeline can be considered as flow of water in a river. XML SAX events pass through the pipeline components one after another. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

15 Request Processing By Cocoon
9/18/2018 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, ... Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

16 Dynamic Content from XSP
9/18/2018 Dynamic Content from XSP <!-- A simple XSP Page --> <xsp:page language="java” xmlns:xsp=“ > <page> <title>A Simple XSP Page</title> <content> <para>dynamically generated list:</para> <ul> <xsp:logic> for (int i=0; i < 3; i++) { <li> Item <xsp:expr>i</xsp:expr> </li> } </xsp:logic> </ul> </content> </page> </xsp:page> Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

17 What Are Web Services? 9/18/2018
Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

18 Most commonly used definition:
9/18/2018 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. Interoperability => Ability of a program running within one environment ( programming language, h/w platform, OS, …) to communicate, by invoking method calls or exchanging messages, to programs running within another environment. Portability => Ability of a program to run within different environments. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

19 SOAP 1.1 XML based protocol for exchange of information
9/18/2018 SOAP 1.1 SOAP 1.1 Message Structure SOAP Envelope [Header Element] Header Entries Body Element [Fault 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. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

20 WSDL 1.1 A WSDL document describes
9/18/2018 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} Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

21 What is a Web Services Platform ?
9/18/2018 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 Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

22 Java Platforms and Standards
9/18/2018 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 HP WSP => HP Web Services Platform HP WSR => HP Web Services Registry HP WST => HP Web Services Transactions JWSDK => Java Web Services Development Kit Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

23 Observations on Java Platforms and Standards
9/18/2018 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 ... Large Data -- Large XML fragments within SOAP Body Huge attachments ( as per SOAP w/ Attachments specification ) Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

24 Cocoon and Web Services
9/18/2018 Cocoon and Web Services Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

25 Cocoon as a Presentation Framework for Web-Services
9/18/2018 Cocoon as a Presentation Framework for Web-Services Client Tier Web Tier Web Services WS Registry Enterprise Apps Servlet Container Cocoon Cocoon is a natural fit in the web-tier, between a browser and backend web-services. In this configuration, a program running within Cocoon environment invokes web-services, reformats the obtained data ( for presentation ) and serves it to the client. HP has developed the abstraction of XScript within Cocoon processing model that makes it possible to do pure xml computation within an XSP. HP has developed the SOAP and UDDI logicsheets ( tag libraries for the XSP environment ) that make it extremely easy to invoke web-services from Cocoon environment. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

26 Cocoon as a Processing Framework for Web Services
9/18/2018 Cocoon as a Processing Framework for Web Services Client Tier Web Tier Web Services WS Registry Enterprise Apps Servlet Container Cocoon P1 P2 It turns out that SAX based processing model of Cocoon is also very good to build complex web services that Need to manage state across multiple interactions, Support asynchronous messaging Support reliable delivery of messages …. Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

27 A Simple Cocoon Web Application
9/18/2018 A Simple Cocoon Web Application Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

28 9/18/2018 Problem Statement Use Google Web Services API from 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. HP WSP => HP Web Services Platform HP WSR => HP Web Services Registry HP WST => HP Web Services Transactions JWSDK => Java Web Services Development Kit Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

29 Application Components
9/18/2018 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 HP WSP => HP Web Services Platform HP WSR => HP Web Services Registry HP WST => HP Web Services Transactions JWSDK => Java Web Services Development Kit Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

30 Application Architecture
9/18/2018 Application Architecture Cocoon Servlet Google WS Browser Maps request to index.html index.html …/search?q=... SOAP request SOAP response executes google.xsp Search results in HTML Applies search-results.xsl Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

31 Demo Architecture Browser Cocoon Servlet
9/18/2018 Demo Architecture Cocoon Servlet Browser Maps request to index-local.html index.html …/search-local?q=... Reads google.results Search results in HTML Applies search-results.xsl Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here

32 Web Application Demo [Walk through the Design, Sources and the Demo]
9/18/2018 Web Application Demo [Walk through the Design, Sources and the Demo] HP WSP => HP Web Services Platform HP WSR => HP Web Services Registry HP WST => HP Web Services Transactions JWSDK => Java Web Services Development Kit Tuesday, September 18, 2018Tuesday, September 18, 2018Tuesday, September 18, 2018 Choose View, Header and Footer to enter text here


Download ppt "Cocoon: A Framework for Web Services"

Similar presentations


Ads by Google