1 / 32

Cocoon: A Framework for Web Services

Using Cocoon to consume and produce Web Services. Cocoon: A Framework for Web Services. Pankaj Kumar pankaj_kumar@hp.com Web Services Architect, HP Middleware. Presentation Goals. Understand Apache Cocoon, Web Services and how Cocoon can be used to build

Download Presentation

Cocoon: A Framework for Web Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Cocoon to consume and produce Web Services Cocoon: A Framework for Web Services Pankaj Kumar pankaj_kumar@hp.com Web Services Architect, HP Middleware Choose View, Header and Footer to enter text here

  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 Choose View, Header and Footer to enter text here

  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 Choose View, Header and Footer to enter text here

  4. Presentation Topics • What is Cocoon? • Exploring Cocoon • What are Web Services? • Cocoon and Web Services • A Simple Cocoon Web Application Choose View, Header and Footer to enter text here

  5. What is Cocoon? Choose View, Header and Footer to enter text here

  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 Choose View, Header and Footer to enter text here

  7. Apache Cocoon ( Contd. ) • Promotes separation of Content, Logic, Presentation and Management in web-site design. Choose View, Header and Footer to enter text here

  8. Exploring Cocoon Choose View, Header and Footer to enter text here

  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://localhost:8080/cocoon Choose View, Header and Footer to enter text here

  10. Cocoon Welcome Page Choose View, Header and Footer to enter text here

  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 Choose View, Header and Footer to enter text here

  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 Choose View, Header and Footer to enter text here

  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 ! ). Choose View, Header and Footer to enter text here

  14. 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:match> <map:handle-errors> <map:transform src="context://stylesheets/system/error2html.xsl"/> <map:serialize status-code="500"/> </map:handle-errors> </map:pipeline> Choose View, Header and Footer to enter text here

  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, ... Choose View, Header and Footer to enter text here

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

  17. What Are Web Services? Choose View, Header and Footer to enter text here

  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. Choose View, Header and Footer to enter text here

  19. 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. SOAP 1.1 Message Structure SOAP Envelope Header Entries [Header Element] Body Element [Fault Element] SOAP 1.1 Choose View, Header and Footer to enter text here

  20. 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 1.1 WSDL 1.1 Document Structure WSDL Document [Types] {Messages} {PortTypes} {Bindings} {Services} Choose View, Header and Footer to enter text here

  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 Choose View, Header and Footer to enter text here

  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 Choose View, Header and Footer to enter text here

  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 • ... Choose View, Header and Footer to enter text here

  24. Cocoon and Web Services Choose View, Header and Footer to enter text here

  25. WS Registry Cocoon Web Services Servlet Container Client Tier Web Tier Enterprise Apps Cocoon as a Presentation Framework for Web-Services Choose View, Header and Footer to enter text here

  26. WS Registry P1 Cocoon Servlet Container Web Services P2 Client Tier Web Tier Enterprise Apps Cocoon as a Processing Framework for Web Services Choose View, Header and Footer to enter text here

  27. A Simple Cocoon Web Application Choose View, Header and Footer to enter text here

  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. Choose View, Header and Footer to enter text here

  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 Choose View, Header and Footer to enter text here

  30. Application Architecture Cocoon Servlet Google WS Browser http://<host>/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 Choose View, Header and Footer to enter text here

  31. Demo Architecture Cocoon Servlet Browser http://<host>/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 Choose View, Header and Footer to enter text here

  32. Web Application Demo [Walk through the Design, Sources and the Demo] Choose View, Header and Footer to enter text here

More Related