cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz Kossakowski <>
Subject Re: Migrating to Cocoon 2.2... calling servlets from Cocoon: ServletServiceGenerator
Date Thu, 22 Nov 2007 15:41:14 GMT
Josh2007 pisze:
> Hi,
> I'm migrating from Cocoon 2.1 to Cocoon 2.2.
> Cocoon 2.2 is deployed as a servlet in Tomcat along with 2 other servlets:
> Axis 2 and eXist xmldb.
> It seems with Cocoon 2.2 I can call my 2 other servlets from Cocoon and get
> any xml result they will generate in my sitemap.

Yep, but you can only call servlets that are registered as Spring-beans, using configuration
like this[1]:
	<bean id="org.apache.cocoon.servletservice.demo1.servlet"
    	<servlet:context mount-path="/test1">
				<entry key="foo" value="baz"/>
				<entry key="demo2" value-ref="org.apache.cocoon.servletservice.demo2.servlet"/>

In most cases it's not a big problem to configure servlets that way.

> Can I do that with ServletServiceGenerator? Is there any example? I've been
> searching without success for now.

Actually, ServletServiceGenerator does something more than just fetching data from other servlets
(it's a job of servlet source). Take a look at this example[2]:

      <!-- This is a test of basic servlet services functionality
           servletService generator makes a HTTP POST request on servlet:test2:/basic-service.
           Generator posts content of test.xml file and returns to the pipeline result of
service call.
      <map:match pattern="test5">
        <map:generate type="servletService" src="test.xml">
          <map:parameter name="service" value="servlet:test2:/basic-service?caller=generator"/>
        <map:serialize type="xml"/>

The comment above the match explains what happens quite well. The idea is to fetch data that
based on POSTed data. This way servlet:test2:/basic-service can be viewed as pipeline *fragment*
looking even implementation[2] looks like this:
      <!-- This basic service pipeline takes POSTed XML and applays simple transformation
on it -->
      <map:match pattern="basic-service">
        <map:generate src="service-consumer:"/>
        <map:transform src="service-test.xsl">
          <map:parameter name="caller" value="{request-param:caller}"/>
        <map:serialize type="xml"/>

> Will my sitemap look like this?
> <map:pipeline>       
>   <map:match pattern="test">
>     <map:generate src="anySoapRequest.xml" type="ServletServiceGenerator"/>
>     <map:serialize type="xml"/>
>   </map:match>       
> </map:pipeline>

I would say it would look like this:
  <map:match pattern="test">
    <map:generate src="servlet:axis:/anySoapRequest" type="file"/>
    <map:serialize type="xml"/>

> Thanks for your help,

I suggest to take a closer look at cocoon-servlet-service-sample module that contains some
demos. Of course they are not ideal but at least they present the most important features
of Servlet
Service Framework.

I hope that helps a little.


Grzegorz Kossakowski
Committer and PMC Member of Apache Cocoon

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message