cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Edwards <>
Subject Re: WebService Proxy
Date Tue, 01 Mar 2005 22:34:42 GMT
Hi Andrea,
I use the webservicesproxy generator (wspg) to call a struts action 
which returns the result as xhtml to be displayed by cocoon.
Basically we're trying to incorporate chunks of an existing web 
application into my new cocoon app.
Cocoon calls the struts action which displays a bunch of check boxes 
from which the user selects. The action from this page is proxied back 
to the struts application which generates xml data based on the user's 
selection. This gets captured by the pipeline and ultimately processed 
by cocoon.

Here's the process:

Flow function to initiate the call to the remote struts application:

function addPlantLink(plNodeNum){
    print("In addPlantLink. Assigning a general ledger account to the 
current node (asset).");
    print("In addPlantLink: glNodeNum = " + glNodeNum);
    cocoon.sendPage("plantEnquiry", {});

Pipeline snippet that processes the call from flow:

            <!-- this is called from the flow to return the information 
as xml -->
            <map:match pattern="plantEnquiry">
                <map:generate type="wsproxy" 
                    <map:parameter name="wsproxy-method" value="post"/>
                  <!-- display the struts form...-->
                  <map:serialize type="html"/>

            <!-- 1st returned uri from struts page. Run directly, don't 
go through flow... -->
            <map:match pattern="*/">
                <map:generate type="wsproxy" 
                    <map:parameter name="wsproxy-method" value="post"/>
                  <map:serialize type="html"/>

The {global:proxy-src} is the url of the container context of the Struts 
webapp we're calling (eg:

Final step is to call a flow function from the sitemap (this is actually 
the struts form's action):

            <map:match pattern="*/aim/">
                <map:call function="saveAssetLinks"/>

This function calls the processToDOM function to grab the xml returned 
by the struts function and process it.
function saveAssetLinks(){
    //Run the last leg of the external linkage stuff and then grab the 
xml document returned...
    print("In saveAssetLinks. glNodeNum = " + glNodeNum);
    var pipelineUtil = 
    var document = pipelineUtil.processToDOM("webHierarchyLink", null);
    if(document != null){
        print("saveAssetLinks: authorityAssetLinks document returned. 
        print("saveAssetLinks: calling insertAssetLink(). Inserting 
links as component child of node.");
        //We have a positive document situation. Now we need to save 
data to aualclnk
        var bOk = insertAssetLink(document);
            print("Error assigning links: " + message);
//            cocoon.request.setAttribute("message", message);
            cocoon.session.setAttribute("message", message);

    } else {
        print("saveAssetLinks: No asset link document returned!");
        print("Finished inserting asset links.");
        print("saveAssetLinks: Persisting updated document back to 
        var uri = "hrcy_xml/" + 
Trim(getNodeAttributeValue(gHrcyDoc.getFirstChild(),"description")) + 
        saveDocument(gHrcyDoc, uri);
    } catch (error) {
        print("Could not save hierarchy: " + error);
    print("saveAssetLinks: disposing pipelineUtil.");
    print("saveAssetLinks: display tree-menu.");
    //Display hierarchy again/

    cocoon.redirectTo("tree-menu", true)
The things to consider are that the html returned from the struts app 
needs to be xhtml. I haven't had time to play with the Tidy options yet 
so I just made sure the struts developer ponied up well formed html.
This might give you a few starting points to get going.



Andrea Vagliengo wrote:

> Hi all,
> I want to forward a HTTP request from my cocoon application to a remote
> (servlet) application, then while the former waits the last performs its
> operations. I want to capture back the result of these computations mo 
> make them
> available for local cocoon styling.
> I have found some documentation about the WebServiceProxy Generator, 
> but I don't
> undestand HOW the "resulting XML content" is taken from the remote 
> webapp to the
> local cocoon webapp. There is no indication about how to associate the
> particular proxy to the pointed resource, and nothing about how the 
> XML-based
> produced response is captured by cocoon application.
> Does anybody of you can help me?
> Thanks a lot,
> best regards
> Andrea
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

This email is from Civica Pty Limited and it, together with any attachments,
is confidential to the intended recipient(s) and the contents may be legally
privileged or contain proprietary and private information. It is intended
solely for the person to whom it is addressed. If you are not an intended
recipient, you may not review, copy or distribute this email. If received in
error, please notify the sender and delete the message from your system
Any views or opinions expressed in this email and any files transmitted with
it are those of the author only and may not necessarily reflect the views of
Civica and do not create any legally binding rights or obligations
whatsoever. Unless otherwise pre-agreed by exchange of hard copy documents
signed by duly authorised representatives, contracts may not be concluded on
behalf of Civica by email. 
Please note that neither Civica nor the sender accepts any responsibility
for any viruses and it is your responsibility to scan the email and the
attachments (if any). All email received and sent by Civica may be monitored
to protect the business interests of Civica. 

View raw message