You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Lars Huttar <la...@sil.org> on 2006/01/25 18:19:08 UTC

how to post in 2.1.7?

Hello,
An application we're developing has a need to send a POST request to a 
web server (with XML content), and receive a response as XML.
If it were a GET request, I could just use the File generator (or 
map:aggregate, as there are 3 requests I need to send).

It seems like the intended way to send a POST request is to use the 
CInclude transformer; but I see from 
http://issues.apache.org/jira/browse/COCOON-1365 and other emails that 
the post method of CInclude is broken in 2.1.7.

At http://issues.apache.org/jira/browse/COCOON-1365, Vadim Gritsenko 
says that "new HTTPRequestTransformer should have this functionality", 
but as far as I can find, there is no HTTPRequestTransformer included 
with 2.1.7 or 2.1.8.

I see there is ProxyTransformer with javadoc at 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/portal/transformation/ProxyTransformer.html, 
but I don't see user docs about it, or a description of parameters, or 
an indication of whether we can use this as a transformer in the sitemap.

There is a Web Services Proxy generator, described at 
http://cocoon.apache.org/2.1/userdocs/wsproxy-generator.html, but it 
only seems to support the GET method, and there's no documentation of 
parameters. Ah, there is more documentation for it in 
samples/blocks/proxy/. It supports POST! OK, I'll try that.

So it goes with Cocoon... the functionality is often there, if you can 
only discover it!

Anybody have better suggestions for sending a POST-with-XML and getting 
XML data back? Would Flowscript be a better choice? One requirement of 
our application is that the requests will need to be sent sequentially, 
not in parallel. In fact, we will not even be able to form the nth 
request until we have the results from the n-1th request.

Lars



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how to post in 2.1.7?

Posted by Lars Huttar <la...@sil.org>.
Armaz Mellati wrote:
> Hi
>
>
> Another approach I would try is to use HttpClient [1] from a flow script. In flow, you can instantiate Java objects and use them.
> So, you need simply create an HttpClient object, set its parameters and do a post-method. Get the response and do what ever you want
> to do with it. 
> Well, actually it is better to do most of the logic in a Java class of your own and just use your Java class from from the flow. 
> By the way, HttpClient jar files are already part of Cocoon. 
>
> Hope it helps.
>
> Regards,
> Armaz Mellati
>
> [1] http://jakarta.apache.org/commons/httpclient/
>   
Thanks... I will look into this.
Lars


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: how to post in 2.1.7?

Posted by Armaz Mellati <ar...@uninett.no>.
Hi


Another approach I would try is to use HttpClient [1] from a flow script. In flow, you can instantiate Java objects and use them.
So, you need simply create an HttpClient object, set its parameters and do a post-method. Get the response and do what ever you want
to do with it. 
Well, actually it is better to do most of the logic in a Java class of your own and just use your Java class from from the flow. 
By the way, HttpClient jar files are already part of Cocoon. 

Hope it helps.

Regards,
Armaz Mellati

[1] http://jakarta.apache.org/commons/httpclient/

> -----Original Message-----
> From: Lars Huttar [mailto:lars_huttar@sil.org] 
> Sent: 27. januar 2006 00:46
> To: users@cocoon.apache.org
> Cc: Huttar, Lars (E-mail)
> Subject: Re: how to post in 2.1.7?
> 
> I've been asking about how to do a post in Cocoon 2.1.7.
> I made progress, in that I can now post using Cinclude. This 
> was accomplished by applying the patch at
> http://issues.apache.org/bugzilla/show_bug.cgi?id=32491
> 
> However, I then discovered that the remote servlet I'm 
> connecting to doesn't actually return XML... it returns XML 
> embedded in Javascript embedded in HTML. :-p CInclude can't 
> handle a non-wellformed-XML response; you get SAX parsing 
> errors. (Even if you try to serialize immediately as HTML.)
> 
> Then while googling I came upon the following Q&A from this list:
> 
> On /Mon Apr 26 13:42:46 CDT 2004 , Upayavira wrote:/
> > Antonio Fernandez wrote:
> >
> > >/Hello everyone,
> > />/
> > />/I'm already lost trying to embed an external application into my 
> > Cocoon app, />/I've tried a couple of things extracted from 
> searches 
> > on this list, />/ />/First, I tried something quite simple:
> > />/
> > />/    <map:act type="request">
> > />/      <map:generate
> > />/src="http://localhost:XXXX/externalApp/index.jsp{requestQuery}" 
> > <http://localhost:XXXX/externalApp/index.jsp%7BrequestQuery%7D%22>
> > />/type="html"/>
> > />/     <map:transform src="myApp/resources/xsl/extTransform.xsl">
> > />/      <map:parameter name="use-request-parameters" value="true"/>
> > />/     </map:transform>
> > />/     <map:serialize type="html"/>
> > />/    </map:act>
> > />/
> > />/And I was quite happy until I reached the first POST. Since I 
> > wanted to POST />/form data to the external servlet, I used 
> cinclude, 
> > />/the way it is documented in the Cocoon docs, section "Including 
> > External />/XML(advanced)", but at that point I begun getting error 
> > />/messages since the HTML generated by the external 
> servlet was not 
> > correctly />/formed.(lack of ending tags), and they weren't being 
> > />/corrected by the html generator as in the first try.
> > />/
> > />/So, I'd like to know if there is some kind of "html-tidy" 
> > transformer, />/similar to the html generator, which I could insert 
> > between the />/cinclude generation and my application 
> stylesheet, to 
> > feed it with correct />/data. Or, if you have any other 
> advice, I'd be 
> > very grateful to hear />/it.
> > />/
> > />/
> > /If you're using cinclude to request content that is coming in as 
> > HTML, use a cocoon:/ protocol request in your cinclude 
> request. Then, 
> > the page referred to by the cocoon: protocol is served by a 
> pipeline 
> > that begins with the HTML generator.
> >
> > Makes sense?
> >
> > Regards, Upayavira
> Antonio's question is exactly the one I want an answer for: 
> how can you send a POST request, and process the 
> non-well-formed-XML response?
> 
> I'm hoping I can use Upayavira's solution, but so far I don't 
> understand it.
> Upayavira, the reason (as I understand it) that Antonio is 
> using cinclude is that the HTML generator can't send a POST. 
> The documentation refers to post requests, but it seems to 
> mean that the HTML generator can use an *incoming* post 
> request as a source, not that it can send a POST request and 
> use the response as a source -- hence it says to omit the src 
> parameter. 
> (http://cocoon.apache.org/2.1/userdocs/html-generator.html)
> 
> So, if Antonio's cinclude uses a cocoon:/ URL that refers to 
> another pipeline that uses an HTML generator, the HTML 
> generator will have to pass the POST request on to the 
> external servlet. But, the HTML generator can't pass on a 
> POST request, as far as I know. (Please correct me if I'm 
> wrong!) The web proxy generator (or is it transformer?) can 
> pass on a POST request, I believe... but can it handle 
> non-well-formed XML as a response and turn it into something 
> Cocoon can work with?
> 
> Any advice is appreciated.
> 
> Lars
> 
> 
> ---------------------------------------------------------------------
> 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: how to post in 2.1.7?

Posted by Lars Huttar <la...@sil.org>.
I've been asking about how to do a post in Cocoon 2.1.7.
I made progress, in that I can now post using Cinclude. This was 
accomplished by applying the patch at 
http://issues.apache.org/bugzilla/show_bug.cgi?id=32491

However, I then discovered that the remote servlet I'm connecting to 
doesn't actually return XML... it returns XML embedded in Javascript 
embedded in HTML. :-p
CInclude can't handle a non-wellformed-XML response; you get SAX parsing 
errors. (Even if you try to serialize immediately as HTML.)

Then while googling I came upon the following Q&A from this list:

On /Mon Apr 26 13:42:46 CDT 2004 , Upayavira wrote:/
> Antonio Fernandez wrote:
>
> >/Hello everyone,
> />/
> />/I'm already lost trying to embed an external application into my Cocoon app,
> />/I've tried a couple of things extracted from searches on this list,
> />/
> />/First, I tried something quite simple:
> />/
> />/    <map:act type="request">
> />/      <map:generate
> />/src="http://localhost:XXXX/externalApp/index.jsp{requestQuery}" <http://localhost:XXXX/externalApp/index.jsp%7BrequestQuery%7D%22>
> />/type="html"/>
> />/     <map:transform src="myApp/resources/xsl/extTransform.xsl">
> />/      <map:parameter name="use-request-parameters" value="true"/>
> />/     </map:transform>
> />/     <map:serialize type="html"/>
> />/    </map:act>
> />/
> />/And I was quite happy until I reached the first POST. Since I wanted to POST
> />/form data to the external servlet, I used cinclude,
> />/the way it is documented in the Cocoon docs, section "Including External
> />/XML(advanced)", but at that point I begun getting error
> />/messages since the HTML generated by the external servlet was not correctly
> />/formed.(lack of ending tags), and they weren't being
> />/corrected by the html generator as in the first try.
> />/
> />/So, I'd like to know if there is some kind of "html-tidy" transformer,
> />/similar to the html generator, which I could insert between the
> />/cinclude generation and my application stylesheet, to feed it with correct
> />/data. Or, if you have any other advice, I'd be very grateful to hear
> />/it.
> />/  
> />/
> /If you're using cinclude to request content that is coming in as HTML, 
> use a cocoon:/ protocol request in your cinclude request. Then, the page 
> referred to by the cocoon: protocol is served by a pipeline that begins 
> with the HTML generator.
>
> Makes sense?
>
> Regards, Upayavira
Antonio's question is exactly the one I want an answer for: how can you 
send a POST request, and process the non-well-formed-XML response?

I'm hoping I can use Upayavira's solution, but so far I don't understand it.
Upayavira, the reason (as I understand it) that Antonio is using 
cinclude is that the HTML generator can't send a POST. The documentation 
refers to post requests, but it seems to mean that the HTML generator 
can use an *incoming* post request as a source, not that it can send a 
POST request and use the response as a source -- hence it says to omit 
the src parameter. 
(http://cocoon.apache.org/2.1/userdocs/html-generator.html)

So, if Antonio's cinclude uses a cocoon:/ URL that refers to another 
pipeline that uses an HTML generator, the HTML generator will have to 
pass the POST request on to the external servlet. But, the HTML 
generator can't pass on a POST request, as far as I know. (Please 
correct me if I'm wrong!)
The web proxy generator (or is it transformer?) can pass on a POST 
request, I believe... but can it handle non-well-formed XML as a 
response and turn it into something Cocoon can work with?

Any advice is appreciated.

Lars


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how to post in 2.1.7?

Posted by Lars Huttar <la...@sil.org>.
Lars Huttar wrote:
> Lars Huttar wrote:
>> Hello,
>> An application we're developing has a need to send a POST request to 
>> a web server (with XML content), and receive a response as XML.
>> If it were a GET request, I could just use the File generator (or 
>> map:aggregate, as there are 3 requests I need to send). But these 
>> approaches don't support POST.
>>
>> It seems like the intended way to send a POST request is to use the 
>> CInclude transformer; but I see from 
>> http://issues.apache.org/jira/browse/COCOON-1365 and other emails 
>> that the post method of CInclude is broken in 2.1.7.
>>
>> At http://issues.apache.org/jira/browse/COCOON-1365, Vadim Gritsenko 
>> says that "new HTTPRequestTransformer should have this 
>> functionality", but as far as I can find, there is no 
>> HTTPRequestTransformer included with 2.1.7 or 2.1.8.
>>
>> I see there is ProxyTransformer with javadoc at 
>> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/portal/transformation/ProxyTransformer.html, 
>> but I don't see user docs about it, or a description of parameters, 
>> or an indication of whether we can use this as a transformer in the 
>> sitemap.
>>
>> There is a Web Services Proxy generator, described at 
>> http://cocoon.apache.org/2.1/userdocs/wsproxy-generator.html, but it 
>> only seems to support the GET method, and there's no documentation of 
>> parameters. Ah, there is more documentation for it in 
>> samples/blocks/proxy/. It supports POST! OK, I'll try that.
>>
> Oh... I don't see a way to supply post data to the request, other than 
> using a form.
> I don't think I want a form. I want the post data to be 
> dynamically-constructed XML (specifically, ArcXML, probably 
> constructed with an XSP page), not form data values.
Unless there is a way to make a form submit post data without having to 
involve the browser.

The purpose of the pipeline I'm trying to set up is to provide an image 
service that can be accessed from a web page with a simple <img 
src="http://mycocoonserver/genereate-map-image?country=US"/>, not a form.
Is there a way to have my pipeline internally submit a form, submitting 
a dynamically-generated XML document (not name-value pairs) to a 
specified URL -- without sending the form to a browser first?

Lars


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


How to structure a website with cocoon

Posted by Peter Neu <pe...@gmx.net>.
Hello,

I would like to develop a classic web site with cocoon. I'm used to doing
this with tiles. I looked at the examples how the guys at daisy and forest
do that but I find their concepts rather unfamiliar. 

I also found this example
http://www.cocooncenter.org/articles/navigation.html but is this how it
should be done?

I realize that another alternative would be doing this with extra piplelines
for every component in a website. Like this: 

<map:match pattern="publicpages/**">
   <map:aggregate element="page">
     <map:part src="cocoon:/menu-part/{1}"/>
     <map:part src="cocoon:/header-part/{1}"/>
     <map:part src="cocoon:/footer-part/{1}"/>
   </map:aggregate>
    ...transform etc.
</map:match>

But does anyone have a little (working) example? 


Cheers,
Pete





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how to post in 2.1.7?

Posted by Lars Huttar <la...@sil.org>.
Lars Huttar wrote:
> Lars Huttar wrote:
>> Hello,
>> An application we're developing has a need to send a POST request to 
>> a web server (with XML content), and receive a response as XML.
>> If it were a GET request, I could just use the File generator (or 
>> map:aggregate, as there are 3 requests I need to send). But these 
>> approaches don't support POST.
>>
>> It seems like the intended way to send a POST request is to use the 
>> CInclude transformer; but I see from 
>> http://issues.apache.org/jira/browse/COCOON-1365 and other emails 
>> that the post method of CInclude is broken in 2.1.7.
>>
>> At http://issues.apache.org/jira/browse/COCOON-1365, Vadim Gritsenko 
>> says that "new HTTPRequestTransformer should have this 
>> functionality", but as far as I can find, there is no 
>> HTTPRequestTransformer included with 2.1.7 or 2.1.8.
>>
>> I see there is ProxyTransformer with javadoc at 
>> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/portal/transformation/ProxyTransformer.html, 
>> but I don't see user docs about it, or a description of parameters, 
>> or an indication of whether we can use this as a transformer in the 
>> sitemap.
>>
>> There is a Web Services Proxy generator, described at 
>> http://cocoon.apache.org/2.1/userdocs/wsproxy-generator.html, but it 
>> only seems to support the GET method, and there's no documentation of 
>> parameters. Ah, there is more documentation for it in 
>> samples/blocks/proxy/. It supports POST! OK, I'll try that.
>>
> Oh... I don't see a way to supply post data to the request, other than 
> using a form.
> I don't think I want a form. I want the post data to be 
> dynamically-constructed XML (specifically, ArcXML, probably 
> constructed with an XSP page), not form data values.
>> So it goes with Cocoon... the functionality is often there, if you 
>> can only discover it!
>>
>> Anybody have better suggestions for sending a POST-with-XML and 
>> getting XML data back? Would Flowscript be a better choice? One 
>> requirement of our application is that the requests will need to be 
>> sent sequentially, not in parallel. In fact, we will not even be able 
>> to form the nth request until we have the results from the n-1th 
>> request.
> If flowscript can do it, would someone point me to an example or 
> documentation? Specifically, what I need to be able to do is create a 
> POST request, with XML data content (from upstream in the pipeline or 
> from a cocoon: URI), send it to a web service, and receive the XML 
> data in the response for further processing.
>
> Thanks,
> Lars
>
P.S.
One option is to use Eric Boisvert's PostClient transformer, posted to 
this list on Dec. 6. That looks like it will do exactly the job I need. 
However, it's a headache to compile a non-standard component, because 
then we have to make sure the jar file and Cocoon config changes get 
distributed to every development, test, and production server that might 
need them, and then make sure the addition gets preserved whenever we 
upgrade Cocoon in the future... on all those servers.
So if there is a more standard way to do this, I'd love to hear about it!

Also, please consider this a vote for the PostClient (or 
PostRequestTransformer?) or something with equivalent functionality  
(HTTPRequestTransformer?) to be included in the standard Cocoon package 
in the future!

Thanks,
Lars



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how to post in 2.1.7?

Posted by Lars Huttar <la...@sil.org>.
Lars Huttar wrote:
> Hello,
> An application we're developing has a need to send a POST request to a 
> web server (with XML content), and receive a response as XML.
> If it were a GET request, I could just use the File generator (or 
> map:aggregate, as there are 3 requests I need to send). But these 
> approaches don't support POST.
>
> It seems like the intended way to send a POST request is to use the 
> CInclude transformer; but I see from 
> http://issues.apache.org/jira/browse/COCOON-1365 and other emails that 
> the post method of CInclude is broken in 2.1.7.
>
> At http://issues.apache.org/jira/browse/COCOON-1365, Vadim Gritsenko 
> says that "new HTTPRequestTransformer should have this functionality", 
> but as far as I can find, there is no HTTPRequestTransformer included 
> with 2.1.7 or 2.1.8.
>
> I see there is ProxyTransformer with javadoc at 
> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/portal/transformation/ProxyTransformer.html, 
> but I don't see user docs about it, or a description of parameters, or 
> an indication of whether we can use this as a transformer in the sitemap.
>
> There is a Web Services Proxy generator, described at 
> http://cocoon.apache.org/2.1/userdocs/wsproxy-generator.html, but it 
> only seems to support the GET method, and there's no documentation of 
> parameters. Ah, there is more documentation for it in 
> samples/blocks/proxy/. It supports POST! OK, I'll try that.
>
Oh... I don't see a way to supply post data to the request, other than 
using a form.
I don't think I want a form. I want the post data to be 
dynamically-constructed XML (specifically, ArcXML, probably constructed 
with an XSP page), not form data values.
> So it goes with Cocoon... the functionality is often there, if you can 
> only discover it!
>
> Anybody have better suggestions for sending a POST-with-XML and 
> getting XML data back? Would Flowscript be a better choice? One 
> requirement of our application is that the requests will need to be 
> sent sequentially, not in parallel. In fact, we will not even be able 
> to form the nth request until we have the results from the n-1th request.
If flowscript can do it, would someone point me to an example or 
documentation? Specifically, what I need to be able to do is create a 
POST request, with XML data content (from upstream in the pipeline or 
from a cocoon: URI), send it to a web service, and receive the XML data 
in the response for further processing.

Thanks,
Lars


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org