home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / wsproxy-generator.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  18.4 KB  |  352 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "document-v10.dtd">
  18. <document>
  19.   <header>
  20.     <title>Portal Syndication with Web Services and Cocoon</title>
  21.     <version>1.0</version>
  22.     <type>Technical document</type>
  23.     <authors>
  24.       <person name="Ivelin Ivanov" email="ivelin@apache.org"/>
  25.     </authors>
  26.     <abstract>This document describes the Web Service ProxyGenerator of Cocoon.</abstract>
  27.   </header>
  28.   <body>
  29.     <s1 title="What Is Web Syndication?">
  30.       <p>Web Site Syndication has gained popularity as more and more web sites cross reference each
  31.         other, not only by a single hyperlink, but also by embedding parts of their content. The
  32.         idea was pioneered by Netscape with their Rich Site Summary (RSS)
  33.         (<link href="http://www.oasis-open.org/cover/rss.html">http://www.oasis-open.org/cover/rss.html</link>)
  34.         XML format. RSS was developed in early 1999 to populate Netscape's My Netscape portal with
  35.         external newsfeeds ("channels"). Since then RSS has taken on a life of its own and now
  36.         thousands of Web sites use RSS as a "what's new" mechanism to drive traffic their way.
  37.       </p>
  38.       <p>The current RSS 1.0 standard is an application of Resource Description Framework (RDF)
  39.         (<link href="http://www.w3.org/TR/rdf-schema/">http://www.w3.org/TR/rdf-schema/</link>). RDF
  40.         is a framework for describing and interchanging metadata. The RDF framework is extensible
  41.         and allows adding new types of entities. It also gives meaning to resources to enable
  42.         automated processing of Web resources.
  43.       </p>
  44.       <p>RSS is unarguably an example of an organically grown and widely accepted standard. For long
  45.         it was not endorsed by any of the popular standards committees. Even so it quickly became
  46.         popular and found a large number of creative uses. Lately though it has reached its limits.
  47.         There is a demand for more advanced portal syndication which RSS cannot satisfy.
  48.       </p>
  49.     </s1>
  50.  
  51.     <s1 title="Going beyond RSS with Web Services">
  52.       <p>Latest generation web portals demand more than simply posting cross linked news stories
  53.         from RSS. Embedding and personalizing rich content and behavior from remote portals is
  54.         becoming necessity. Limited success has been achieved through complex and sophisticated
  55.         backend integration via proprietary or Web Services compliant protocols. Recognizing the
  56.         growing demand, influential organizations have attempted to develop new languages such as:
  57.       </p>
  58.  
  59.       <s2 title="Web Services Experience Language (WSXL)">
  60.         <p>
  61.           (<link href="http://www.webservices.org/index.php/article/articleview/345/">http://www.webservices.org/index.php/article/articleview/345/</link>)
  62.         </p>
  63.         <p>
  64.           <em>"WSXL is a Web services centric component model for interactive Web applications. WSXL
  65.             is designed to achieve two main goals: enable businesses to distribute Web applications
  66.             through multiple revenue channels and enable new services or applications to be created
  67.             by leveraging existing applications across the Web."
  68.           </em>
  69.         </p>
  70.       </s2>
  71.  
  72.       <s2 title="Web Services Inspection Language (WSIL)">
  73.         <p>
  74.           (<link href="http://www.webservices.org/index.php/article/articleview/85/">http://www.webservices.org/index.php/article/articleview/85/</link>)
  75.         </p>
  76.         <p>
  77.           <em>"The specification allows a Web services provider to publish a WS-Inspection (WSIL)
  78.             document which lists the services on offer and their corresponding WSDL (Web services
  79.             description language) files. The convention is that the WSIL document should be called
  80.             "inspection.wsil" and be located at a common entry point to the web site. This paves the
  81.             way for future Web services "crawlers" to locate and parse WSIL documents for Web
  82.             service search engines."        
  83.           </em>
  84.         </p>
  85.       </s2>
  86.  
  87.       <s2 title="Web Services for Remote Portals (WSRP)">
  88.         <p>
  89.           (<link href="http://www.oasis-open.org/committees/wsrp/">http://www.oasis-open.org/committees/wsrp/</link>)
  90.         </p>
  91.         <p>
  92.           <em>"Defining an XML and Web services standard that will allow the plug-n-play of visual,
  93.             user-facing Web services with portals or other intermediary Web applications"
  94.           </em>
  95.         </p>
  96.       </s2>
  97.  
  98.       <s2 title="Web Services for Interactive Applications">
  99.         <p>
  100.           (<link href="http://www.oasis-open.org/committees/wsia/">http://www.oasis-open.org/committees/wsia/</link>)
  101.         </p>
  102.         <p>
  103.           <em>"Create an XML and web services centric framework for interactive web applications.
  104.             The designs must achieve two main goals: enable businesses to distribute web
  105.             applications through multiple revenue channels, and enable new services or applications
  106.             to be created by leveraging existing applications across the Web."
  107.           </em>
  108.         </p>
  109.       </s2>
  110.  
  111.       <p>While these efforts are certainly worthwhile and promising, it will most likely take years
  112.         before they pass the filters of real life use before they can claim widespread adoption. All
  113.         of them ask for a thick infrastructure layer to support implementations. While possible, it
  114.         is unlikely that mainstream deployment will be achieved instantly.
  115.       </p>
  116.       <p>Not all is lost though. Fortunately, there is way to satisfy a large portion of the
  117.         syndication requirements by applying already established technologies and tools. We will
  118.         illustrate the architecture of a possible solution using an open source framework for XML
  119.         Publishing - Apache Cocoon.
  120.       </p>
  121.     </s1>
  122.  
  123.     <s1 title="Apache Cocoon">
  124.       <p>
  125.         (<link href="http://cocoon.apache.org/index.html">http://cocoon.apache.org/index.html</link>)
  126.       </p>
  127.       <p>
  128.         <em>"Apache Cocoon is an XML publishing framework that raises the usage of XML and XSLT
  129.           technologies for server applications to a new level. Designed for performance and
  130.           scalability around pipelined SAX processing, Cocoon offers a flexible environment based
  131.           on a separation of concerns between content, logic and style. To top this all off,
  132.           Cocoon's centralized configuration system and sophisticated caching help you to create,
  133.           deploy and maintain rock-solid XML server applications".
  134.         </em>
  135.       </p>
  136.       <p>First, let's describe a typical use case scenario: User logs in to a familiar portal and
  137.         happily surfs about. At some point the user clicks on a link which leads to a strange page.
  138.         It has the portal logo, even shows the same login id but still looks very different and
  139.         unfriendly ... After some time and frustration the user gets used to switching back and
  140.         forth between the two faces of the portal ... while looking for another provider which
  141.         offers both services in a coherent graphical interface.
  142.       </p>
  143.       <p>For those who have never had similar experience, we will give a popular example. Yahoo! Autos
  144.         (<link href="http://autos.yahoo.com/finance.html?refsrc=autos/insurance">http://autos.yahoo.com/finance.html?refsrc=autos/insurance</link>)
  145.         offers an easy to use interactive catalog of cars. However when it comes to insuring an
  146.         automobile, applying for a loan or buying a car, the web site hyperlinks to a co-branded
  147.         page of another company. For example Lending Tree
  148.         (<link href="https://www.lendingtree.com/newauto/secure/ctl_borrower.asp?page=loan_selection&verb=continue&O_loan_type=LOAN_TYPE_AUTO&bp=yahooautos&source=40050&alliance=true&SITEID=&templxlname=&templxssn1=&templxssn2=&templxssn3=">https://www.lendingtree.com/newauto/.....</link> )
  149.         will show Yahoo! Autos logo at the top of the screen, however the rest of the page looks
  150.         very different than any other Yahoo! page. All the personalization spoils that a Yahoo! user
  151.         enjoys are lost as soon as the application for a loan begins. Not only the colors and layout
  152.         are different. A login session with Yahoo! does not carry over to Lending Tree. On top of
  153.         that a pop-up window appears when switching between the two sites, which reads "You are
  154.         about to view pages over a secure connection ...". When added up these "negligible"
  155.         inadequacies, lead to an overall poor experience, which is certainly not the original
  156.         intent of the Yahoo! content producers.
  157.       </p>
  158.       <p>Now as we have an idea of how things are not supposed to work, we will show that
  159.         outsourcing interactive components to a third party site, while preserving the look &
  160.         feel of the original portal is still possible when done right. As we mentioned Cocoon offers
  161.         a solution. Since Cocoon is a very sophisticated framework, an indepth analysis of its
  162.         features is beyond the scope of this text to cover.
  163.       </p>
  164.     </s1>
  165.  
  166.     <s1 title="Web Services Proxy to the rescue">
  167.       <p>The latest version of Cocoon is 2.1 and it has a new Web Service Proxy component. It is
  168.         this component which we shall focus on for the reminder of the text. To follow the rest of
  169.         the article, it will be useful (but not essential) to have a basic knowledge of Cocoon 2.
  170.       </p>
  171.       <p>Combined with the XMLForm (which is not part of Cocoon anymore)
  172.         component of Cocoon 2 and XSLT, the Web Service Proxy component allows vendors to share
  173.         interactive content with little effort. The Web Service Proxy takes advantage of the fact
  174.         that a Cocoon web application produces XML content, which is later translated into multiple
  175.         presentation formats, like HTML or WML. Once the proxy is plugged in the Cocoon sitemap, it
  176.         transparently pipes browser requests to a remote web application and returns the response
  177.         back to the sitemap for local styling. Receiving a client independent XML format, allows the
  178.         local site to pull content and style it with XSLT with the desired Look & Feel.
  179.       </p>
  180.       <p>
  181.         <strong>
  182.           Q. Ok, styling presentation is easy to understand, but how is a form submitted to the original site?
  183.         </strong>
  184.       </p>
  185.       <p>The XMLForm component is the answer. It uses W3C XForms included in the XML content which
  186.         allows the end user to directly interact with the remote server through the embedding site.
  187.         The form markup in the XML content of an embedded page uses relative URL address for the
  188.         target action, when the end user submits, the form data is sent to the containing site,
  189.         which captures the form data and the relative URL. The Web Service Proxy then takes this
  190.         information and re-submits it to the original site. It then reads the XML response and makes
  191.         it available to the sitemap for styling again.
  192.       </p>
  193.       <p>
  194.         <strong>Q. Hmm ... a typical web application maintains a user session while navigating.
  195.           How is the containing site propagating the end user session to the embedded site?
  196.         </strong>
  197.       </p>
  198.       <p>The answer is simple. The Web Service Proxy simply hooks to the end user session and
  199.         automatically starts its own session with the remote site. If the remote site requires
  200.         authentication, then the developer of the local web site has to pass the user credentials
  201.         as parameters to the WebServiceProxyGenerator.
  202.       </p>
  203.       <p>
  204.         <strong>Q. What transport protocols are supported?</strong>
  205.       </p>
  206.       <p>HTTP 1.0, HTTP 1.1, HTTPS.</p>
  207.       <p>Below we will illustrate the architecture of the solution with some example code and
  208.         figures.
  209.       </p>
  210.       <figure src="images/wsproxy_Proxies.png" alt="Figure 1 - Traditional Http Proxy vs Cocoon Web Service Proxy"/>
  211.       <p>
  212.         <em>Figure 1 - Architecture of the Web Service Proxy Solution. As opposed to a traditional
  213.           proxy server, the Web Services Proxy captures user input and allows the web site to remain
  214.           coherent even when the functionality for some of its components is delivered remotely.
  215.         </em>
  216.       </p>
  217.       <figure src="images/wsproxy_CompositePage.png" alt="Figure 2 - Illustration of the data flow for a composite page"/>
  218.       <p>
  219.         <em>Figure 2 - Illustration of the data flow for a composite page. Some of the content is
  220.           locally constructed, the rest is obtained remotely. Finally the same styling is applied
  221.           and the user facing page appears consistent.
  222.         </em>
  223.       </p>
  224.       <p>Now we will show a snippet of the sitemap which employs the Web Service Proxy. Notice its
  225.         brevity! The Web Service Proxy completely handles the content and navigation logic between
  226.         the two portals. Only stylesheets are additionally required to translate the remotely
  227.         retrieved documents into a user friendly format.
  228.       </p>
  229.       <source><![CDATA[
  230.   <?xml version="1.0"?>
  231.   <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  232.  
  233.     <!-- =========================== Components ================== -->
  234.     <map:components>
  235.       <map:generators default="file">
  236.         <map:generator name="wsproxy" logger="sitemap.generator.wsproxy"
  237.           src="org.apache.cocoon.generation.WebServiceProxyGenerator"/>
  238.       </map:generators>
  239.     </map:components>
  240.  
  241.     <!-- =========================== Pipelines =================== -->
  242.     <map:pipelines>
  243.       <map:pipeline>
  244.         <!-- Interactive Web Application Syndication  -->
  245.         <map:match pattern="*">
  246.           <map:generate type="wsproxy" label="xml"
  247.             src="http://{request:serverName}:{request:serverPort}{request:contextPath}/samples/xmlform/wizard?cocoon-view=xml"/>
  248.           <map:transform src="stylesheets/newWizard2html.xsl"/>
  249.           <map:transform src="context://samples/stylesheets/xmlform/xmlform2html.xsl"/>
  250.           <map:serialize type="html"/>
  251.         </map:match>
  252.       </map:pipeline>
  253.     </map:pipelines>
  254.   </map:sitemap>
  255.    ]]></source>
  256.  
  257.       <figure src="images/wsproxy_Sequence.png" alt="Figure 3 - sequence diagram"/>
  258.       <p>
  259.         <em>Figure 3 - Above is a sequence diagram outlining the interaction between the key
  260.           participants in a syndication session.
  261.         </em>
  262.       </p>
  263.       <figure src="images/wsproxy_Screenshot1.png" alt="screen shot 1"/>
  264.       <p>
  265.         <em>Figure 4 - Sample screenshot from a remotely enabled application as it appears
  266.           standalone.
  267.         </em>
  268.       </p>
  269.       <figure src="images/wsproxy_Screenshot2.png" alt="screen shot 2"/>
  270.       <p>
  271.         <em>Figure 5 - Sample screenshot from the same application embedded in another web
  272.           application.
  273.         </em>
  274.       </p>
  275.  
  276.       <p>The content of the original XML page behind these two screenshot follows:</p>
  277.       <source><![CDATA[
  278.   <?xml version="1.0"?>
  279.   <document xmlns:xf="http://apache.org/cocoon/xmlform/1.0">
  280.     <xf:form id="form-feedback" view="userIdentity" action="wizard" method="GET">
  281.       <xf:caption>Personal Information</xf:caption>
  282.       <error>
  283.         <xf:violations class="error"/>
  284.       </error>
  285.       <xf:textbox ref="firstName">
  286.         <xf:caption>First Name</xf:caption>
  287.         <xf:violations class="error"/>
  288.       </xf:textbox>
  289.       ...
  290.       <xf:selectMany ref="role" selectUIType="listbox">
  291.         <xf:caption>Professional roles</xf:caption>
  292.         <xf:item>
  293.           <xf:caption>Geek</xf:caption>
  294.           <xf:value>Geek</xf:value>
  295.         </xf:item>
  296.         <xf:item>
  297.           <xf:caption>Hacker</xf:caption>
  298.           <xf:value>Hacker</xf:value>
  299.         </xf:item>
  300.         ...
  301.       </xf:selectMany>
  302.       ...
  303.       <!-- hidden model attribute -->
  304.       <xf:hidden ref="hidden">
  305.         <xf:value>true</xf:value>
  306.       </xf:hidden>
  307.       ...
  308.       <xf:submit id="next" class="button">
  309.         <xf:caption>Next</xf:caption>
  310.       </xf:submit>
  311.     </xf:form>
  312.  
  313.     <xf:output ref="count" id="show_count" form="form-feedback" class="info">
  314.       <xf:caption>Visits Count</xf:caption>
  315.     </xf:output>
  316.   </document>
  317.    ]]></source>
  318.  
  319.       <p>The listing above contains markup in the XMLForm namespace. It is a presentation
  320.         independent way to specify input controls. Being XForms compliant it is easy to learn and
  321.         use. The XSLT stylesheets used to convert the XML above are very simple and will not be
  322.         listed here. They can found in the Cocoon 2.1 distribution.
  323.       </p>
  324.     </s1>
  325.  
  326.     <s1 title="Conclusion">
  327.       <p>The Web Service Proxy component is tightly integrated with the Cocoon framework and is
  328.         particularly convenient to use in combination with XMLForm to enable syndication of website
  329.         functionality. With the presented sample, we only scratched the service of the possible
  330.         applications. It is easy to see though for a creative mind how it can be extended in
  331.         multiple directions. Although the solution we offered is conveniently applied with Cocoon,
  332.         the concepts are generally applicable outside the framework as well. Exposing a Web
  333.         Application functionality via XML is not just a "neat" feature any more. It opens the gates
  334.         to a constellation of opportunities, not possible with the classical Model-2 approach where
  335.         the business logic is directly tied to a graphical output like HTML.
  336.       </p>
  337.  
  338.       <s2 title="Have more questions?">
  339.         <p>Look at the online demo available in the Cocoon distribution in the samples:
  340.           <code>http://{host}:{port}/{contextPath}/samples/proxy/</code>.
  341.         </p>
  342.         <p>Then study the source code and if you still have questions, join the cocoon users email
  343.           list and ask. If you have ideas for improvement then you are more than welcome to discuss
  344.           it on the cocoon development email list and eventually submit a patch through the Apache
  345.           bug tracking system.
  346.         </p>
  347.       </s2>
  348.     </s1>
  349.   </body>
  350. </document>
  351.  
  352.