Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 61793 invoked from network); 1 Mar 2005 22:35:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 1 Mar 2005 22:35:38 -0000 Received: (qmail 97329 invoked by uid 500); 1 Mar 2005 22:35:33 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 97288 invoked by uid 500); 1 Mar 2005 22:35:33 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 97273 invoked by uid 99); 1 Mar 2005 22:35:33 -0000 X-ASF-Spam-Status: No, hits=1.7 required=10.0 tests=FORGED_MUA_IMS,HTML_50_60,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from Unknown (HELO civmail.civica.com.au) (203.56.2.254) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 01 Mar 2005 14:35:31 -0800 Received: by mail.civica.com.au with Internet Mail Service (5.5.2653.19) id ; Wed, 2 Mar 2005 09:34:50 +1100 Message-ID: <4224EE02.3060806@civica.com.au> From: Tony Edwards To: users@cocoon.apache.org Subject: Re: WebService Proxy Date: Wed, 2 Mar 2005 09:34:42 +1100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C51EAE.DC5AAD00" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C51EAE.DC5AAD00 Content-Type: text/plain; charset="iso-8859-1" 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.request.setAttribute("token",user.userLogin.session_id); cocoon.sendPage("plantEnquiry", {}); } Pipeline snippet that processes the call from flow: The {global:proxy-src} is the url of the container context of the Struts webapp we're calling (eg: http://www.blah.com/webservice) Final step is to call a flow function from the sitemap (this is actually the struts form's action): 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 = cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.Pipeline Util); cocoon.request.setAttribute("token",user.userLogin.session_id); var document = pipelineUtil.processToDOM("webHierarchyLink", null); if(document != null){ print("saveAssetLinks: authorityAssetLinks document returned. Processing..."); 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); if(!bOk){ print("Error assigning links: " + message); // cocoon.request.setAttribute("message", message); cocoon.session.setAttribute("message", message); cocoon.redirectTo("tree-menu",true); return; } } else { print("saveAssetLinks: No asset link document returned!"); return; } try{ print("Finished inserting asset links."); print("saveAssetLinks: Persisting updated document back to disk..."); var uri = "hrcy_xml/" + Trim(getNodeAttributeValue(gHrcyDoc.getFirstChild(),"description")) + ".xml"; saveDocument(gHrcyDoc, uri); } catch (error) { print("Could not save hierarchy: " + error); } print("saveAssetLinks: disposing pipelineUtil."); cocoon.disposeObject(pipelineUtil); print("saveAssetLinks: display tree-menu."); //Display hierarchy again/ //viewHrcy(); //welcome(); cocoon.redirectTo("tree-menu", true) return; } 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. Regards, Tony 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: users-unsubscribe@cocoon.apache.org > For additional commands, e-mail: users-help@cocoon.apache.org > --------------------------------------------------------------------- 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 immediately. 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. --------------------------------------------------------------------- ------_=_NextPart_001_01C51EAE.DC5AAD00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Re: WebService Proxy

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 =3D " + glNodeNum);
    = cocoon.request.setAttribute("token",user.userLogin.session_id)= ;
    = cocoon.sendPage("plantEnquiry", {});
}

Pipeline snippet that processes the call from = flow:

          &nb= sp; <!-- this is called from the flow to return the information =
as xml -->
          &nb= sp; <map:match pattern=3D"plantEnquiry">
          &nb= sp;     <map:generate type=3D"wsproxy" =
src=3D"{global:proxy-src}/plantEnquiryInit.do?webLink=3DY&= amp;amp;token=3D{request-attr:token}">
          &nb= sp;         <map:parameter = name=3D"wsproxy-method" value=3D"post"/>
          &nb= sp;       = </map:generate>  
          &nb= sp;       <!-- display the struts = form...-->
          &nb= sp;       <map:serialize = type=3D"html"/>
          &nb= sp; </map:match>

          &nb= sp; <!-- 1st returned uri from struts page. Run directly, don't =
go through flow... -->
          &nb= sp; <map:match pattern=3D"*/plantEnquiry.do">
          &nb= sp;     <map:generate type=3D"wsproxy" =
src=3D"{global:proxy-src}/plantEnquiry.do?token=3D{request= -attr:token}">   
           =
          &nb= sp;         <map:parameter = name=3D"wsproxy-method" value=3D"post"/>
          &nb= sp;       = </map:generate>      
          &nb= sp;       <map:serialize = type=3D"html"/>
          &nb= sp; = </map:match>         =             =             =  

The {global:proxy-src} is the url of the container = context of the Struts
webapp we're calling (eg: http://www.blah.com/webservice)

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

          &nb= sp; <map:match = pattern=3D"*/aim/webHierarchyLink.do">
          &nb= sp;     <map:call = function=3D"saveAssetLinks"/>
          &nb= sp; </map:match>

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 =3D " + glNodeNum);
    var pipelineUtil =3D
cocoon.createObject(Packages.org.apache.cocoon.components.flow.= util.PipelineUtil);
    = cocoon.request.setAttribute("token",user.userLogin.session_id)= ;
    var document =3D = pipelineUtil.processToDOM("webHierarchyLink", null);
    if(document !=3D null){
        = print("saveAssetLinks: authorityAssetLinks document returned. =
Processing...");
        = 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 = =3D insertAssetLink(document);
        = if(!bOk){
          &nb= sp; print("Error assigning links: " + message);
//          &= nbsp; cocoon.request.setAttribute("message", message);
          &nb= sp; cocoon.session.setAttribute("message", message);
          &nb= sp; cocoon.redirectTo("tree-menu",true);
          &nb= sp; return;
        = }      

    } else {
        = print("saveAssetLinks: No asset link document = returned!");
        = return;
    }
    try{
        = print("Finished inserting asset links.");
        = print("saveAssetLinks: Persisting updated document back to
disk...");
        var uri = =3D "hrcy_xml/" +
Trim(getNodeAttributeValue(gHrcyDoc.getFirstChild(),"descr= iption")) +
".xml";
        = saveDocument(gHrcyDoc, uri);
    } catch (error) {
        = print("Could not save hierarchy: " + error);
    }  
    print("saveAssetLinks: = disposing pipelineUtil.");
    = cocoon.disposeObject(pipelineUtil);  
    print("saveAssetLinks: = display tree-menu.");
    //Display hierarchy again/
    //viewHrcy();
    //welcome();

    = cocoon.redirectTo("tree-menu", true)
    return;
}
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.

Regards,

Tony


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: = users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: = users-help@cocoon.apache.org
>

---------------------------------------------------------------= ------
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 = immediately.

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.

---------------------------------------------------------------= ------

------_=_NextPart_001_01C51EAE.DC5AAD00--