cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: How to transform URL-parameters and XML-input into a XML-DOM structure in a Cocoon 1.5 producer?
Date Sun, 02 Jan 2000 21:49:26 GMT
Johann Bertscheit wrote:
> 
> Hi cocoon-fans,
> 
> I try to use cocoon as a pure XML-Framework for B2B communication.
> In order to achieve this it is neccsessary to transform user input (in
> form of URL / XML - data) to internal XML.
> 
> I have the following problem with cocoon 1.5:
> I want to write a producer with the following semantics:
> 
> the producer should transform:
> 1.) URL-parameters into a XML-DOM structure (the simple case - the URL
> can be accessed with HttpServletRequest request.getQueryString)
> 2.) XML-input (from the http-request) into a XML-DOM structure:
> (the more difficult case:
> - how to get the type of input (the Content-type) and if it is of type
> text/xml?
> - how to get the whole POSTed XML-input into a string?
> - is it possible to access non normal POSTs (a normal browser POST would
> be of Content-type: application/x-www-form-urlencoded - that is not the
> case here: I have Content-type: text/xml)
> 
> How to achieve this?

write your custom producer. Others have expressed the need for such
"Servlet-request xml-izer" and somebody wrote something, but I didn't
myself.

> Does anyone had the same problem and already has such kind of producer?

AFAIK, others tried this direction, but I don't think it's a good one
for performance reasons: you have to read all the request parameters in
order to XML-ize it, but sometimes performance is a non-issue for these
things.

> I havn't found a predefined producer for this purpose.

No, there is none shipped in Cocoon.
 
> {I tried to use the new Cocoon-Producer  "ProducerFromRequest" but it
> dont works in the cocoon 1.5 environment:

ProducerFromRequest is used when the Cocoon engine is called directly by
other software as a library. What you need is more complex than that.

> java.lang.IllegalStateException: Already called getInputStream
>              at
> org.apache.jserv.JServConnection.getReader(JServConnection.java:941)
>              at
> org.apache.cocoon.producer.ProducerFromRequest.getStream(ProducerFromRequest.java:28)
> 
> Does someone know what the problem is here?}

Weird, it never happened to me :/
 
> I know that I must access HttpServletRequest but maybe someone has
> already sample code for this purpose.
> 
> To be more specific here an example of what I want to implement:
> 
> - It sould be possible to send the following pure-URL request to sent to
> Cocoon:
> 
> e.g.
> { echo 'GET /invoke/PriceData?matno=BNX:3000N&ifa=34352542&qty=1
> HTTP/1.0'; echo ''; sleep 1;} | telnet cocoon-host 4444
> 
> this should be mapped by the producer to a XML-Structure:
> 
> e.g.
> <URL-params>
>     <matno>BNX:3000N</matno>
>     <ifa>34352542</ifa>
>     <qty>1</qty>
> </URL-params>
> 
> - It sould be possible to send the following pure-XML request (XML-POST)
> should be sent to Cocoon:
> 
> e.g:
> { echo 'POST /invoke/PriceData HTTP/1.0\nContent-type:
> text/xml\nContent-length:
> 102\n\n<?xmlversion="1.0"?><PriceQuery><matno>BNX:3000N</matno><ifa>34352542</ifa><qty>1</qty></PriceQuery>\n\n\n';
> sleep 10;} | telnet cocoon-host 4444
> 
> e.g.
> <XML-params>
>     <PriceQuery>
>         <matno>BNX:3000N</matno>
>         <ifa>34352542</ifa>
>         <qty>1</qty>
>     </PriceQuery>
> </XML-params>
> 
> - it should be possible to send a mixture of URL and XML input
> parameters >> a merge of above two cases
> 
> How to access the required information in the context of a
> cocoon-producer?

Well, you get the ServletRequest, so you have all you need to XML-ize
it. You just need to write the code :) or find others that did.

Anyway, if you come up with something widely useful, I'll put into the
distribution.
 
-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------



Mime
View raw message