You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sébastien Geindre <se...@meteo.fr> on 2008/01/14 19:17:21 UTC
IncludeTransformer
hi all,
I wonder if i need to set all http header parameters when i user
IncludeTransformer or CIncludeTransformer requesting an external xml
ressrouce via http post ....
any idea ?
thanks.
--
Sébastien Geindre
DPREVI/AERO/DEV
sebastien.geindre __at__ meteo.fr
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: IncludeTransformer -- it works
Posted by "Boisvert, Eric" <eb...@nrcan.gc.ca>.
Yes Eric..
This stx is even cleaner and it works too,
================ post.stx ==================================================
<?xml version="1.0" encoding="UTF-8"?>
<stx:transform xmlns:stx="http://stx.sourceforge.net/2002/ns" version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sf="http://stx.sourceforge.net/2003/functions"
pass-through="all" output-method="xml" strip-space="yes">
<stx:template match="ARCXML">
<stx:process-self filter-method="http://www.ietf.org/rfc/rfc2616.txt#POST" name="wfs">
<stx:with-param name="target">
http://some.esriArcIMS.Server.com/servlet/com.esri.esrimap.Esrimap?ServiceName=someDataStore&CustomService=Query
</stx:with-param>
</stx:process-self>
</stx:template>
</stx:transform>
======================================================================
It runs into an arbitrary XML and sends all the ARCXML query to the server and inserts the result in lieu on the query..
Eric
-----Message d'origine-----
De : Boisvert, Eric [mailto:eboisver@nrcan.gc.ca]
Envoyé : 17 janvier 2008 10:48
À : users@cocoon.apache.org
Objet : RE: IncludeTransformer -- it works
I'll be damned.. It works perfectly !
Here's my pipeline
<map:pipeline>
<map:match pattern="dev/get">
<!-- test STX POST trick -->
<map:generate src="document/ai.xml"/>
<map:transform type="stx" src="style/post.stx"/> <map:serialize type="xml"/> </map:match> </map:pipeline>
It reads a document (ai.xml) that has 2 ARCXML calls - works exactly the same as WFS servers.
========== ai.xml ================================= <?xml version="1.0" encoding="ISO-8859-1"?> <proc> <q1> <ARCXML version="1.0">
<REQUEST>
<GET_FEATURES outputmode="newxml" geometry="true" featurelimit="1">
<LAYER id="litho"/>
<SPATIALQUERY subfields="FIELD1 FIELD2 #SHAPE#">
<FEATURECOORDSYS id="4326"/>
<FILTERCOORDSYS id="4326"/>
<SPATIALFILTER relation="area_intersection">
<ENVELOPE minx="12.5" miny="42.6" maxx="13.29" maxy="43.13"/>
</SPATIALFILTER>
</SPATIALQUERY>
</GET_FEATURES>
</REQUEST>
</ARCXML>
</q1>
<q2>
<ARCXML version="1.0">
<REQUEST>
<GET_FEATURES outputmode="newxml" geometry="true" featurelimit="1">
<LAYER id="litho"/>
<SPATIALQUERY subfields="FIELD3 FIELD4 #SHAPE#">
<FEATURECOORDSYS id="4326"/>
<FILTERCOORDSYS id="4326"/>
<SPATIALFILTER relation="area_intersection">
<ENVELOPE minx="12.5" miny="42.6" maxx="13.29" maxy="43.13"/>
</SPATIALFILTER>
</SPATIALQUERY>
</GET_FEATURES>
</REQUEST>
</ARCXML>
</q2>
</proc>
And here the STX
================ post.stx ==================================================
<?xml version="1.0" encoding="UTF-8"?>
<stx:transform xmlns:stx="http://stx.sourceforge.net/2002/ns" version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sf="http://stx.sourceforge.net/2003/functions"
pass-through="all" output-method="xml" strip-space="yes"> <stx:buffer name="wfs"/> <stx:template match="ARCXML">
<!-- load the ARCXML query in a buffer --> <stx:result-buffer name="wfs" clear="yes">
<ARCXML version="1.0">
<stx:process-children/>
</ARCXML>
</stx:result-buffer>
<!-- now send that baby to the server --> <stx:process-buffer filter-method="http://www.ietf.org/rfc/rfc2616.txt#POST" name="wfs"> <stx:with-param name="target">http://some.esriArcIMS.Server.com/servlet/com.esri.esrimap.Esrimap?ServiceName=someDataStore&CustomService=Query</stx:with-param>
</stx:process-buffer>
</stx:template>
</stx:transform>
And it does work..
STX in pass-through="all" just ignore the tags that does not match and pass them down the stream, it only does something when it matches ARCXML tag. So the result is indeed
<proc>
<q1>
the result of the first query
</q1>
<q2>
the result of the second query
</q2>
</proc>
CQFD ! (french speaking people will understand)
Cheers
Eric
P.S.
Maybe a cleaner stx would be
<stx:process-self filter-method="http://www.ietf.org/rfc/rfc2616.txt#POST" name="wfs"> <stx:with-param name="target">http://some.esriArcIMS.Server.com/servlet/com.esri.esrimap.Esrimap?ServiceName=someDataStore&CustomService=Query</stx:with-param>
</stx:process-self>
No need for a buffer.. I should try.
-----Message d'origine-----
De : Sébastien Geindre [mailto:sebastien.geindre@meteo.fr]
Envoyé : 17 janvier 2008 10:35
À : users@cocoon.apache.org
Objet : Re: IncludeTransformer
> I never try, but I will shortly (like.. Today) for exactly the same
> reasons Sébastien (to fetch data from a remote WFS). STX is a bit
> more tricky that XSLT but in a simple series of WFS calls, it should
> be quite obvious. The great benefit of STX is that it's SAX driven
> (so I don't expect it should build a big buffer - GML documents tends
> to be quite large)
>
Great !!!
Hope you succeed..
> Wish me the best.
>
we do !!! ;)
> Eric
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: IncludeTransformer -- it works
Posted by "Boisvert, Eric" <eb...@nrcan.gc.ca>.
I'll be damned.. It works perfectly !
Here's my pipeline
<map:pipeline>
<map:match pattern="dev/get">
<!-- test STX POST trick -->
<map:generate src="document/ai.xml"/>
<map:transform type="stx" src="style/post.stx"/>
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
It reads a document (ai.xml) that has 2 ARCXML calls - works exactly the same as WFS servers.
========== ai.xml =================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<proc>
<q1>
<ARCXML version="1.0">
<REQUEST>
<GET_FEATURES outputmode="newxml" geometry="true" featurelimit="1">
<LAYER id="litho"/>
<SPATIALQUERY subfields="FIELD1 FIELD2 #SHAPE#">
<FEATURECOORDSYS id="4326"/>
<FILTERCOORDSYS id="4326"/>
<SPATIALFILTER relation="area_intersection">
<ENVELOPE minx="12.5" miny="42.6" maxx="13.29" maxy="43.13"/>
</SPATIALFILTER>
</SPATIALQUERY>
</GET_FEATURES>
</REQUEST>
</ARCXML>
</q1>
<q2>
<ARCXML version="1.0">
<REQUEST>
<GET_FEATURES outputmode="newxml" geometry="true" featurelimit="1">
<LAYER id="litho"/>
<SPATIALQUERY subfields="FIELD3 FIELD4 #SHAPE#">
<FEATURECOORDSYS id="4326"/>
<FILTERCOORDSYS id="4326"/>
<SPATIALFILTER relation="area_intersection">
<ENVELOPE minx="12.5" miny="42.6" maxx="13.29" maxy="43.13"/>
</SPATIALFILTER>
</SPATIALQUERY>
</GET_FEATURES>
</REQUEST>
</ARCXML>
</q2>
</proc>
And here the STX
================ post.stx ==================================================
<?xml version="1.0" encoding="UTF-8"?>
<stx:transform xmlns:stx="http://stx.sourceforge.net/2002/ns" version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sf="http://stx.sourceforge.net/2003/functions"
pass-through="all" output-method="xml" strip-space="yes">
<stx:buffer name="wfs"/>
<stx:template match="ARCXML">
<!-- load the ARCXML query in a buffer -->
<stx:result-buffer name="wfs" clear="yes">
<ARCXML version="1.0">
<stx:process-children/>
</ARCXML>
</stx:result-buffer>
<!-- now send that baby to the server -->
<stx:process-buffer filter-method="http://www.ietf.org/rfc/rfc2616.txt#POST" name="wfs">
<stx:with-param name="target">http://some.esriArcIMS.Server.com/servlet/com.esri.esrimap.Esrimap?ServiceName=someDataStore&CustomService=Query</stx:with-param>
</stx:process-buffer>
</stx:template>
</stx:transform>
And it does work..
STX in pass-through="all" just ignore the tags that does not match and pass them down the stream, it only does something when it matches ARCXML tag. So the result is indeed
<proc>
<q1>
the result of the first query
</q1>
<q2>
the result of the second query
</q2>
</proc>
CQFD ! (french speaking people will understand)
Cheers
Eric
P.S.
Maybe a cleaner stx would be
<stx:process-self filter-method="http://www.ietf.org/rfc/rfc2616.txt#POST" name="wfs">
<stx:with-param name="target">http://some.esriArcIMS.Server.com/servlet/com.esri.esrimap.Esrimap?ServiceName=someDataStore&CustomService=Query</stx:with-param>
</stx:process-self>
No need for a buffer.. I should try.
-----Message d'origine-----
De : Sébastien Geindre [mailto:sebastien.geindre@meteo.fr]
Envoyé : 17 janvier 2008 10:35
À : users@cocoon.apache.org
Objet : Re: IncludeTransformer
> I never try, but I will shortly (like.. Today) for exactly the same
> reasons Sébastien (to fetch data from a remote WFS). STX is a bit
> more tricky that XSLT but in a simple series of WFS calls, it should
> be quite obvious. The great benefit of STX is that it's SAX driven
> (so I don't expect it should build a big buffer - GML documents tends
> to be quite large)
>
Great !!!
Hope you succeed..
> Wish me the best.
>
we do !!! ;)
> Eric
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: IncludeTransformer
Posted by Sébastien Geindre <se...@meteo.fr>.
> I never try, but I will shortly (like.. Today) for exactly the same reasons Sébastien (to fetch data from a remote WFS). STX is a bit more tricky that XSLT but in a simple series of WFS calls, it should be quite obvious. The great benefit of STX is that it's SAX driven (so I don't expect it should build a big buffer - GML documents tends to be quite large)
>
Great !!!
Hope you succeed..
> Wish me the best.
>
we do !!! ;)
> Eric
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: IncludeTransformer
Posted by "Boisvert, Eric" <eb...@nrcan.gc.ca>.
Yet another approach is to use STX.
STX processor in cocoon is Joost (http://joost.sourceforge.net/) which implements external-filter , one of which is POST (maybe you'll have to update the .jar to the most recent version, it's painless, just stop tomcat/cocoon, remove the old jar and replace with the new one, and restart).
The joost documentation says (from the web site):
] Using external SAX2 filters
] Joost implements the usage of external SAX2 filters as described in the WD of the STX specification section 4.19 (CVS version Jul 23
] 2003). Joost uses the TrAX API to instantiate an XSLT transformer object. The actual XSLT implementation (i.e. the
] javax.xml.transform.TransformerFactory) to be used may be controlled by setting the property
] net.sf.joost.trax.TrAXConstants.KEY_XSLT_FACTORY, either as a system property or using TransformerFactory.setAttribute.
] Besides the XSLT (http://www.w3.org/1999/XSL/Transform) and STX (http://stx.sourceforge.net/2002/ns) filter methods, Joost provides
] built-in implementations for the following two additional values of the filter-method attribute:
(blah blah..)
**] http://www.ietf.org/rfc/rfc2616.txt#POST
**] Sends the filter input data per HTTP-POST request to the URL specified in the required target parameter (i.e. <stx:param
**] name="target" ... >). The data of the HTTP response are the result of this filter. The HTTP-POST filter can be used to access web
**] services from STX.
I never try, but I will shortly (like.. Today) for exactly the same reasons Sébastien (to fetch data from a remote WFS). STX is a bit more tricky that XSLT but in a simple series of WFS calls, it should be quite obvious. The great benefit of STX is that it's SAX driven (so I don't expect it should build a big buffer - GML documents tends to be quite large)
Wish me the best.
Eric
-----Message d'origine-----
De : Sébastien Geindre [mailto:sebastien.geindre@meteo.fr]
Envoyé : 17 janvier 2008 05:03
À : users@cocoon.apache.org
Objet : Re: IncludeTransformer
>> Second approach : use transformer given by franco
>> (http://www.mail-archive.com/users@cocoon.apache.org/msg39623.html),
>> but it seems to not be compatible with C2.2.
>>
>> public class HTTPPostTransformer
>> extends AbstractTransformer
>> implements Recyclable, Composable { ...
>>
>>
>> this transformer, written for C2.1, is based on AbstractTransformer.
>> it has compose method which set the manager.
>> Does it still work in C2.2 ?
>>
>
> I think it should work as long as you replace Composable with
> Serviceable interface and compose() with service() method. However, if
> you write your own components from scratch I would suggest to write them as Spring beans instead of Avalon components.
>
>
implements Serviceable make it works...
I am not used with Spring beans... any cocoon links to how make a cocoon transformer based on spring beans ?
thanks again Grzegorz!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: IncludeTransformer
Posted by Sébastien Geindre <se...@meteo.fr>.
>> Second approach : use transformer given by franco
>> (http://www.mail-archive.com/users@cocoon.apache.org/msg39623.html), but
>> it seems to not be compatible with C2.2.
>>
>> public class HTTPPostTransformer
>> extends AbstractTransformer
>> implements Recyclable, Composable { ...
>>
>>
>> this transformer, written for C2.1, is based on AbstractTransformer.
>> it has compose method which set the manager.
>> Does it still work in C2.2 ?
>>
>
> I think it should work as long as you replace Composable with Serviceable interface and compose()
> with service() method. However, if you write your own components from scratch I would suggest to
> write them as Spring beans instead of Avalon components.
>
>
implements Serviceable make it works...
I am not used with Spring beans... any cocoon links to how make a cocoon
transformer based on spring beans ?
thanks again Grzegorz!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: IncludeTransformer
Posted by Grzegorz Kossakowski <gk...@apache.org>.
Sébastien Geindre pisze:
>
>> I see your saga with calling an external service continues
> It's a real saga !!! I am writing the season 2 !!!
>
>> what exactly http header parameters you need to set while
>> calling your service?
>>
> i wrote a WFS transformer which take a WFS xml request and make the http
> post request to a WFS webservice. This transformer need that ALL the xml
> stream is a WFS request. It is build on httpclient library...
>
> public class WFSProxy extends AbstractDOMTransformer {
> ...
>
> protected org.w3c.dom.Document transform(org.w3c.dom.Document document)
> {...}
>
> in transform method, i make the http request...
> Very simple, nothing to parse...before requesting. This is OK.
>
> Now i need to make a transformer which take a subset of xml data and
> make the request.
>
> First approach : use CIncludeTransformer !!
> It makes the httprequest, but it seems that some http parameters are not
> set...
> Which one ? That's the questions...
> How can i log the http header of a request made by CIcludeTransformer ?
To be honest, I have no idea... I fear only looking at source code can give you an answer.
> Second approach : use transformer given by franco
> (http://www.mail-archive.com/users@cocoon.apache.org/msg39623.html), but
> it seems to not be compatible with C2.2.
>
> public class HTTPPostTransformer
> extends AbstractTransformer
> implements Recyclable, Composable { ...
>
>
> this transformer, written for C2.1, is based on AbstractTransformer.
> it has compose method which set the manager.
> Does it still work in C2.2 ?
I think it should work as long as you replace Composable with Serviceable interface and compose()
with service() method. However, if you write your own components from scratch I would suggest to
write them as Spring beans instead of Avalon components.
> In fact, the http post is made, but it fell in parsing the response
> because the transformer is not enable to find a parser :
>
> FilterContentHandler lFilterContentHandler = new
> FilterContentHandler(this);
>
> lSAXParser = (SAXParser)
> this.manager.lookup(SAXParser.ROLE);
>
> lSAXParser.parse(lInputSource, lFilterContentHandler);
>
> How can i handle it in C2.2 ?
What's exactly the exception thrown? This should work ok.
> Third approach (season3 !!!) : C2.2 block !!!
Third approach would be implementing your own servlet making WFS call and using postable source but
it won't be much easier so I think writing transformer makes sense in this case.
> thanks for helping.
No problem.
--
Grzegorz Kossakowski
Committer and PMC Member of Apache Cocoon
http://reflectingonthevicissitudes.wordpress.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: IncludeTransformer
Posted by Andy Stevens <in...@googlemail.com>.
Sébastien Geindre wrote:
> How can i log the http header of a request made by CIcludeTransformer ?
One possibility would be to use Axis' tcpmon utility
(http://ws.apache.org/axis/java/user-guide.html#AppendixUsingTheAxisTCPMonitorTcpmon)?
Just change the CInclude to use localhost and configure tcpmon to
forward requests to the real service.
Andrew.
--
http://pseudoq.sourceforge.net/ Open source java Sudoku solver
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: IncludeTransformer
Posted by Sébastien Geindre <se...@meteo.fr>.
> I see your saga with calling an external service continues
It's a real saga !!! I am writing the season 2 !!!
> what exactly http header parameters you need to set while
> calling your service?
>
i wrote a WFS transformer which take a WFS xml request and make the http
post request to a WFS webservice. This transformer need that ALL the xml
stream is a WFS request. It is build on httpclient library...
public class WFSProxy extends AbstractDOMTransformer {
...
protected org.w3c.dom.Document transform(org.w3c.dom.Document document)
{...}
in transform method, i make the http request...
Very simple, nothing to parse...before requesting. This is OK.
Now i need to make a transformer which take a subset of xml data and
make the request.
First approach : use CIncludeTransformer !!
It makes the httprequest, but it seems that some http parameters are not
set...
Which one ? That's the questions...
How can i log the http header of a request made by CIcludeTransformer ?
Second approach : use transformer given by franco
(http://www.mail-archive.com/users@cocoon.apache.org/msg39623.html), but
it seems to not be compatible with C2.2.
public class HTTPPostTransformer
extends AbstractTransformer
implements Recyclable, Composable { ...
this transformer, written for C2.1, is based on AbstractTransformer.
it has compose method which set the manager.
Does it still work in C2.2 ?
In fact, the http post is made, but it fell in parsing the response
because the transformer is not enable to find a parser :
FilterContentHandler lFilterContentHandler = new FilterContentHandler(this);
lSAXParser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
lSAXParser.parse(lInputSource, lFilterContentHandler);
How can i handle it in C2.2 ?
Third approach (season3 !!!) : C2.2 block !!!
thanks for helping.
--
Sébastien Geindre
DPREVI/AERO/DEV
sebastien.geindre __at__ meteo.fr
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: IncludeTransformer
Posted by Grzegorz Kossakowski <gk...@apache.org>.
Sébastien Geindre pisze:
> hi all,
>
> I wonder if i need to set all http header parameters when i user
> IncludeTransformer or CIncludeTransformer requesting an external xml
> ressrouce via http post ....
I see your saga with calling an external service continues. Before I advise to you taking another
approach I would like to hear from you what exactly http header parameters you need to set while
calling your service?
--
Grzegorz Kossakowski
Committer and PMC Member of Apache Cocoon
http://reflectingonthevicissitudes.wordpress.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org