Re: Flowscript continuation from external reply: SOLVED!

2006-02-22 Thread Andrew Madu
Derek,Could you perhaps add some sample code to the wiki site to help the next poor bloke that has to attempt this?! as soon as I get a spare moment I will upload all relevant class files and flowscript code to the wiki.regardsAndrew

Re: Flowscript continuation from external reply: SOLVED!

2006-02-21 Thread Derek Hohls
Andrew
 
Could you perhaps add some sample code to the wiki site to
help the next poor bloke that has to attempt this?!
 
Thanks
Derek

>>> [EMAIL PROTECTED] 2006/02/22 04:41 AM >>>

Hi,
just to let you know that I have successfully implemented webservice 
calls to Paypal into my site via flowscript.

Andrew

> Andrew Madu wrote:
>
>> Hi Simone,
>>
>>> I supposed you was not going to call a webservice (which is 
>>> server to server comunication) but send the user to another 
>>> site, and then receive back (thru the user browser) the result 
>>> of the transaction. This is what i asked in the first few lines 
>>> of my first answer. If you have to call a webservice (your 
>>> server connects to the other server, the user notices nothing) 
>>> then the aproach is radically different.
>>
>>
>> yes I am aware of this, and sorry for any confusion. I am just 
>> looking at both approaches and wish to find a solution to both. 
>> Ultimately for those credit clearing facilities that offer a 
>> webservice (SOAP) solution, I would like to implement that into 
>> my project.
>
> Oh ok, I was just missing the point :)
>
>>
>>
>> I have a pretty clear idea of how to implement the first issue 
>> that I made my original question against. I would now like to 
>> tackle the option of implementing a webservice call into my website.
>>
>> Could you direct me to any documentation on calls to webservices 
>> from cocoon within flowscript?
>
> I don't know of any facility for calling webservices directly from 
> inside a flowscript. I think you will have to use any webservice 
> engine/client you need (Axis, of HTTPClient if it's a rest or 
> whatever else) as if you were going to use it inside any other web 
> technology or java program.
>
> Simone
>
> -- 
> Simone Gianni
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED] 
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 




-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
[EMAIL PROTECTED]


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Flowscript continuation from external reply: SOLVED!

2006-02-21 Thread Andrew Madu


Hi,
just to let you know that I have successfully implemented webservice  
calls to Paypal into my site via flowscript.


Andrew


Andrew Madu wrote:


Hi Simone,

I supposed you was not going to call a webservice (which is  
server  to server comunication) but send the user to another  
site, and then  receive back (thru the user browser) the result  
of the transaction.  This is what i asked in the first few lines  
of my first answer. If  you have to call a webservice (your  
server connects to the other  server, the user notices nothing)  
then the aproach is radically  different.



yes I am aware of this, and sorry for any confusion. I am just   
looking at both approaches and wish to find a solution to both.   
Ultimately for those credit clearing facilities that offer a   
webservice (SOAP) solution, I would like to implement that into  
my  project.


Oh ok, I was just missing the point :)




I have a pretty clear idea of how to implement the first issue  
that I  made my original question against. I would now like to  
tackle the  option of implementing a webservice call into my website.


Could you direct me to any documentation on calls to webservices  
from  cocoon within flowscript?


I don't know of any facility for calling webservices directly from  
inside a flowscript. I think you will have to use any webservice  
engine/client you need (Axis, of HTTPClient if it's a rest or  
whatever else) as if you were going to use it inside any other web  
technology or java program.


Simone

--
Simone Gianni

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Flowscript continuation from external reply

2006-02-21 Thread Bertrand Delacretaz

Le 21 févr. 06 à 17:57, Andrew Madu a écrit :
...Could you direct me to any documentation on calls to webservices  
from cocoon within flowscript?..


Have a look at http://wiki.apache.org/cocoon/FlowAndWebServices -  
dunno how well this works but it might be worth testing.


-Bertrand

smime.p7s
Description: S/MIME cryptographic signature


Re: Flowscript continuation from external reply

2006-02-21 Thread Andrew Madu
Hi  Simone,I don't know of any facility for calling webservices directly from inside a flowscript. I think you will have to use any webservice engine/client you need (Axis, of HTTPClient if it's a rest or whatever else) as if you were going to use it inside any other web technology or java program. for those that may be interested I came across a thread which is a good starting point for flow and web services:http://java2.5341.com/msg/28421.htmlAndrew

Re: Flowscript continuation from external reply

2006-02-21 Thread Simone Gianni

Andrew Madu wrote:


Hi Simone,

I supposed you was not going to call a webservice (which is server  
to server comunication) but send the user to another site, and then  
receive back (thru the user browser) the result of the transaction.  
This is what i asked in the first few lines of my first answer. If  
you have to call a webservice (your server connects to the other  
server, the user notices nothing) then the aproach is radically  
different.



yes I am aware of this, and sorry for any confusion. I am just  
looking at both approaches and wish to find a solution to both.  
Ultimately for those credit clearing facilities that offer a  
webservice (SOAP) solution, I would like to implement that into my  
project.


Oh ok, I was just missing the point :)




I have a pretty clear idea of how to implement the first issue that I  
made my original question against. I would now like to tackle the  
option of implementing a webservice call into my website.


Could you direct me to any documentation on calls to webservices from  
cocoon within flowscript?


I don't know of any facility for calling webservices directly from 
inside a flowscript. I think you will have to use any webservice 
engine/client you need (Axis, of HTTPClient if it's a rest or whatever 
else) as if you were going to use it inside any other web technology or 
java program.


Simone

--
Simone Gianni

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Flowscript continuation from external reply

2006-02-21 Thread Andrew Madu

Hi Simone,

I supposed you was not going to call a webservice (which is server  
to server comunication) but send the user to another site, and then  
receive back (thru the user browser) the result of the transaction.  
This is what i asked in the first few lines of my first answer. If  
you have to call a webservice (your server connects to the other  
server, the user notices nothing) then the aproach is radically  
different.


yes I am aware of this, and sorry for any confusion. I am just  
looking at both approaches and wish to find a solution to both.  
Ultimately for those credit clearing facilities that offer a  
webservice (SOAP) solution, I would like to implement that into my  
project.


I have a pretty clear idea of how to implement the first issue that I  
made my original question against. I would now like to tackle the  
option of implementing a webservice call into my website.


Could you direct me to any documentation on calls to webservices from  
cocoon within flowscript?


Andrew

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Flowscript continuation from external reply

2006-02-21 Thread Simone Gianni




Hi Andrew,
I supposed you was not going to call a webservice (which is server to
server comunication) but send the user to another site, and then
receive back (thru the user browser) the result of the transaction.
This is what i asked in the first few lines of my first answer. If you
have to call a webservice (your server connects to the other server,
the user notices nothing) then the aproach is radically different.

Simone

Andrew Madu wrote:
Hi Simone,
  
  
  1) Instead of using
redirectTo, set up a page with a link to the external site (like a jx
page), then use sendPageAndWait to send this page to the user, he will
click on the link, go to the external site and all the rest, while your
flow will be suspended until the external site will redirect him to
your continuation and the flow will restart. This is a clean solution,
but involves one more step for the user.

2) Create a webContinuation in your flow (you can do this in _javascript_
flow), before the redirectTo. This way you have a "bookmark" in your
flow the user can be redirected to, even if you haven't stopped the
flow directly. This is quite a dirtier solution, but avoids the extra
click. Here is the pseudocode:
  
  
  
  
  
  wouldn't a nicer
way to be to call a webservice? So for example:
   
   var webServiceVal =
cocoon.callWebservice(bizData.fname etc etc etc)
   
  
   try {
if (webServiceVal == true) {
}else{
  
  
}
   } catch (e) {
//Some problem has occured
msg2 = e.toString();
   }
  
  
  How do I call a webservice and pass it
parameters in flowscript?
  
  
  
  
  Andrew






Re: Flowscript continuation from external reply

2006-02-21 Thread Andrew Madu
Hi Simone,1) Instead of using redirectTo, set up a page with a link to the external site (like a jx page), then use sendPageAndWait to send this page to the user, he will click on the link, go to the external site and all the rest, while your flow will be suspended until the external site will redirect him to your continuation and the flow will restart. This is a clean solution, but involves one more step for the user.2) Create a webContinuation in your flow (you can do this in _javascript_ flow), before the redirectTo. This way you have a "bookmark" in your flow the user can be redirected to, even if you haven't stopped the flow directly. This is quite a dirtier solution, but avoids the extra click. Here is the pseudocode:wouldn't a nicer way to be to call a webservice? So for example:		var webServiceVal = cocoon.callWebservice(bizData.fname etc etc etc)		try {		if (webServiceVal == true) {		}else{		}	} catch (e) {		//Some problem has occured		msg2 = e.toString();	}How do I call a webservice and pass it parameters in flowscript?Andrew

Re: Flowscript continuation from external reply

2006-02-21 Thread Simone Gianni




Andrew Madu wrote:
Hi Simone,
  many thanks for
your suggestions.

You're welcome :)

  
  
  
  How so? This is
what comes back to me:
  
  
  www.mysite.com/continuation-id/value-returned
  
  
  What happens
next? How do I get the value-returned into the if statement
following the var bizdata line?
  
  

This is not simple. If you can manipulate the return url, try to have
the value-returned passed as a parameter (like
www.yoursite.com/continuation-id.continue?value-returned=X ) . 

If you can't, then you will have to parse the URL by yourself inside
the flow, and to do this you have to access the underlying JAVA request
object, since the FOM object does not have methods to access the
requestURI.

This is dirty, and YMMV, but it's done this way :

var objectmodel =
Packages.org.apache.cocoon.components.CocoonComponentManager.getCurrentEnvironment().getObjectModel();
var jrequest =
Packages.org.apache.cocoon.environment.ObjectModelHelper.getRequest(objectmodel);
var uri = jrequest.getRequestURI();
var value-returned = uri.substring(uri.lastIndexOf('/') + 1);

I don't know of a way to pass parameters from the sitemap to a
continuation (you can pass them with 

OR you can try to rewrite the url, (a match that uses a map:redirect-to
uri="{1}.continue?value-returned={2}") but it's getting dirtier and
dirtier and don't know if it works well at all.


   


Hope this helps,
Simone

-- 
Simone Gianni





Re: Flowscript continuation from external reply

2006-02-21 Thread Jason Johnston
Andrew Madu wrote:
> Hi Simone,
> many thanks for your suggestions.
> 
>> 1) Instead of using redirectTo, set up a page with a link to the
>> external site (like a jx page), then use sendPageAndWait to send this
>> page to the user, he will click on the link, go to the external site
>> and all the rest, while your flow will be suspended until the external
>> site will redirect him to your continuation and the flow will restart.
>> This is a clean solution, but involves one more step for the user.
> 
> I have implemented the following so far:
> 
> function getUserOrder() {
> ..
> ..
> cocoon.sendPageAndWait("confirmStage")
> }

It's not really related to the issue at hand, but instead of issuing a
sendPageAndWait() to a pipeline that just calls another flow function,
you could call that flow function confirmStage() directly and save some
complexity.

> 
> confirmStage is a sitemap function call:
> 
> 
> 
> 
> 
> 
> to:
> 
> function confirmStage() {
> //2. Get card details.
> var form = new Form("forms/CreditCardDetails.xml");
> form.showForm("CreditCardDetails.xml", {"userGlobal":userGlobal});
> var model = form.getModel();
> var bizData = {"fname" : model.fname, "lname" : model.lname,
> "account_no" : model.account_no, "credit" : model.credit, "month" :
> model.month, "year" : model.year}
> 
> try {
> if (value-returned == true) {
> }else{
> }
> } catch (e) {
> //Some problem has occured
> msg2 = e.toString();
> }
> }
> 
> So I am making a sendPageAndWait to a form which reads like this in the
> html:
> 
> http://www.externalsite.com/test.asp>" name="Form1" method="post"
> onsubmit="forms_onsubmit(); ">
>  name="continuation-id" />
> ...
> 
> The user enters their credit card details and clicks submit which posts
> the form to externalsite.com. 
> 
> Now, at this point, this is where I get confused. You say:
> 
> *'while your flow will be suspended until the external site will
> redirect him to your continuation'*
> 
> How so? This is what comes back to me:
> 
> www.mysite.com/continuation-id/value-returned
> 
> What happens next? How do I get the *value-returned *into the if
> statement following the var bizdata line?

IIUC, you're just making an HTTP request to an external URL, passing it
a few parameters, and getting back a one-line text result which you need
to parse?  You can do that all within flow by using the HTTPClient
library: http://jakarta.apache.org/commons/httpclient/ (included with
Cocoon).

So instead of your form posting directly to the external site, have it
post to your continuation like normal, then in your flowscript read the
user's inputted values from the form, assemble them into a HTTPClient
request, send that request to the external URL, and parse the response
however you need to.

Is this what you're wanting to do?


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Flowscript continuation from external reply

2006-02-21 Thread Andrew Madu
Hi Simone,many thanks for your suggestions.1) Instead of using redirectTo, set up a page with a link to the external site (like a jx page), then use sendPageAndWait to send this page to the user, he will click on the link, go to the external site and all the rest, while your flow will be suspended until the external site will redirect him to your continuation and the flow will restart. This is a clean solution, but involves one more step for the user.I have implemented the following so far:function getUserOrder() {        ..	..	cocoon.sendPageAndWait("confirmStage")}confirmStage is a sitemap function call:		to:function confirmStage() {		//2. Get card details.	var form = new Form("forms/CreditCardDetails.xml");	form.showForm("CreditCardDetails.xml", {"userGlobal":userGlobal});	var model = form.getModel();	var bizData = {"fname" : model.fname, "lname" : model.lname, "account_no" : model.account_no, "credit" : model.credit, "month" : model.month, "year" : model.year}	try {		if (value-returned == true) {			}else{		}	} catch (e) {		//Some problem has occured		msg2 = e.toString();	}}So I am making a sendPageAndWait to a form which reads like this in the html:www.externalsite.com/test.asp" name="Form1" method="post" >...The user enters their credit card details and clicks submit which posts the form to externalsite.com. Now, at this point, this is where I get confused. You say:'while your flow will be suspended until the external site will redirect him to your continuation'How so? This is what comes back to me:www.mysite.com/continuation-id/value-returnedWhat happens next? How do I get the value-returned into the if statement following the var bizdata line?many thanksAndrew

Re: Flowscript continuation from external reply

2006-02-21 Thread Simone Gianni




Hi Andrew,
first question. When you say "pass variables to an external site" you
mean "redirect the user to an external site, like a payment gateway,
and then the external site will redirect the user back to me" right?

In that case, the redirectTo function does not suspend the current
execution, and there is no "redirectAndWait" function, so you are
sending the user to the site, but the flow is not waiting for the
response.

You can solve in two ways :

1) Instead of using redirectTo, set up a page with a link to the
external site (like a jx page), then use sendPageAndWait to send this
page to the user, he will click on the link, go to the external site
and all the rest, while your flow will be suspended until the external
site will redirect him to your continuation and the flow will restart.
This is a clean solution, but involves one more step for the user.

2) Create a webContinuation in your flow (you can do this in _javascript_
flow), before the redirectTo. This way you have a "bookmark" in your
flow the user can be redirected to, even if you haven't stopped the
flow directly. This is quite a dirtier solution, but avoids the extra
click. Here is the pseudocode:

continuation = createWebcontinuation();
if (value-returned == null) {
    redirectTo(externalSite + continuation.id);
} else {
    if (value-returned == true) {
       etc etc
    }
}

You have to check if there is a returned value because when the user is
redirected back to your site the flow will restart from the line
immediately after the creation of the continuation, so you have no way
to determine if this is the first time the user is entering this flow 
or if it's returning from the external site if not checking for the
presence of the return value.

Hope this helps,
Simone

Andrew Madu wrote:
Hi,
  I have a
flowscript function which passes some variables to an external site.
The site will send back a success or failure confirmation based upon
the parameters passed. What I want to do next is continue on the from
the next point in time after the external site was contacted, so:
  
  
  I want to create
some flowscript which passes variables to an external site, (https://www.externalsite.com/test.asp?contiuation-id=xxx,
var1=x,var2=x) for example, gets a response back from the external site
(http://www.mysite.com/continuation-id/value-returned), and based on the response
sent back does something else following the initial call to the
external site. How do I do this in flowscript? 
  
  
  So what i'm
thinking is something like:
  
  
  function getResults() {
  
  
   cocoon.redirectTo("https://www.externalsite.com/test.asp?contiuation-id=xxx,
var1=x,var2=x")
  
  
   if
(value-returned == 'true') {
   do this
   }else{
   do this
   }
  }
  
  
  How do I get back to the point after cocoon.redirectTo() using
the returned continuation-id?
  
  
  thanks in advance
  
  
  Andrew

-- 
Simone Gianni