Re: [Dev] [ESB] JavaScript API for Script mediator

2014-06-02 Thread Ramindu Deshapriya
Hi Dushan,

Thanks. It seems that the functions available via the Rhino JAR are
available within the Script mediator as well.

However, when sending a payload with integer values, the integers seem to be
rewritten in to the payload as float values. 

In the following instance;

if (paymentMethodRef != null  paymentMethodRef !=   paymentMethodRef
!= null) {payload.PaymentMethodRef
= eval((+ paymentMethodRef +));
var numString = 5.0;
var parsedInt = parseInt(numString,10);
print(parsedInt);   
payload.PaymentMethodRef.value = parsedInt; 
}

The print function prints 5 but the payload sent is
PaymentMethodRef:{value:5.0} and the endpoint rejects it.

Is there some other functionality that is causing this? 

Thanks. 



--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411p97611.html
Sent from the WSO2 Development mailing list archive at Nabble.com.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] JavaScript API for Script mediator

2014-05-31 Thread Dushan Abeyruwan
I tried following

script language=js
 ![CDATA[var a=dushanabeyruwan; var b=a.substring(1,6);
print(b)]]/script

it works

[2014-05-31 20:22:35,699]  INFO - LogMediator Progress check = Starting
*pring##ushan*


even you can directly invoke Rihno to see what sort of string funtions
available

dushan@xx:~/poc/rihno/rhino1_7R4/build/rhino1_7R4$ java -jar js.jar
Rhino 1.7 release 4 2014 02 18
js var a=abced
js var b=a.substring(1,3)
js print(b)
bc
js



On Thu, May 29, 2014 at 3:53 PM, Ramindu Deshapriya rasad...@gmail.com
wrote:

 Hi Ishan,

 Thanks. Seems most Synapse-based methods are implemented as JavaScript
 functions. However, when I attempted to use the substring function, it gave
 the following error:

 com.sun.phobos.script.util.ExtendedScriptException:
 org.mozilla.javascript.EcmaError: TypeError: Cannot find function
 substring. (Unknown Source#25) in Unknown Source at line number 25

 Are the basic JavaScript functions not available?

 Thanks.


 On Thu, May 29, 2014 at 3:43 PM, Ishan Jayawardena-2 [via WSO2 Oxygen
 Tank] [hidden email] http://user/SendEmail.jtp?type=nodenode=97416i=0
  wrote:

 You can find it in org.apache.synapse.mediators.bsf.ScriptMessageContext.
 Thanks,
 Ishan.


 On Thu, May 29, 2014 at 3:29 PM, Ramindu Deshapriya [hidden email]
 http://user/SendEmail.jtp?type=nodenode=97415i=0 wrote:

 Hi,

 I am having trouble finding the functions available to the JavaScript API
 when used within a Script Mediator in the ESB. Could someone please
 direct
 me to a list of functions which are available for use within a Script
 Mediator?

 Thanks.



 --
 View this message in context:
 http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411.html
 Sent from the WSO2 Development mailing list archive at Nabble.com.
 ___
 Dev mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=97415i=1
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Ishan Jayawardena
 Senior Software Engineer
 Mobile: a href=tel:%2B94%20%2877%29%20408%202330 value=+94774082330
 target=_blank+94 (77) 408 2330

 ___
 Dev mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=97415i=2
 http://wso2.org/cgi-bin/mailman/listinfo/dev


 --
  If you reply to this email, your message will be added to the
 discussion below:

 http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411p97415.html
  To start a new topic under WSO2 Development, email [hidden email]
 http://user/SendEmail.jtp?type=nodenode=97416i=1
 To unsubscribe from WSO2 Development, click here.
 NAML
 http://wso2-oxygen-tank.10903.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml




 --
 Au revoir!
 Ramindu Deshapriya.

 Member - Sahana Software Foundation http://sahanafoundation.org
 http://rdeshapriya.com

 http://www.facebook.com/rdeshapriya
 http://twitter.com/#%21/rami_desh
 https://plus.google.com/113801459480978566130
 http://www.linkedin.com/profile/view?id=84017607trk=tab_pro
 http://rdeshapriya.com   http://lmakuthan.blogspot.com


 --
 View this message in context: Re: [Dev] [ESB] JavaScript API for Script
 mediator
 http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411p97416.html

 Sent from the WSO2 Development mailing list archive
 http://wso2-oxygen-tank.10903.n7.nabble.com/WSO2-Development-f3.html at
 Nabble.com.

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
Dushan Abeyruwan | Associate Tech Lead
Integration Technologies Team
PMC Member Apache Synpase
WSO2 Inc. http://wso2.com/
Blog:http://dushansview.blogspot.com/
Mobile:(0094)713942042
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] [ESB] JavaScript API for Script mediator

2014-05-29 Thread Ramindu Deshapriya
Hi,

I am having trouble finding the functions available to the JavaScript API
when used within a Script Mediator in the ESB. Could someone please direct
me to a list of functions which are available for use within a Script
Mediator?

Thanks. 



--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411.html
Sent from the WSO2 Development mailing list archive at Nabble.com.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] JavaScript API for Script mediator

2014-05-29 Thread Ishan Jayawardena
You can find it in org.apache.synapse.mediators.bsf.ScriptMessageContext.
Thanks,
Ishan.


On Thu, May 29, 2014 at 3:29 PM, Ramindu Deshapriya rasad...@gmail.com
wrote:

 Hi,

 I am having trouble finding the functions available to the JavaScript API
 when used within a Script Mediator in the ESB. Could someone please direct
 me to a list of functions which are available for use within a Script
 Mediator?

 Thanks.



 --
 View this message in context:
 http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411.html
 Sent from the WSO2 Development mailing list archive at Nabble.com.
 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
Ishan Jayawardena
Senior Software Engineer
Mobile: +94 (77) 408 2330
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [ESB] JavaScript API for Script mediator

2014-05-29 Thread Ramindu Deshapriya
Hi Ishan,

Thanks. Seems most Synapse-based methods are implemented as JavaScript
functions. However, when I attempted to use the substring function, it gave
the following error:

com.sun.phobos.script.util.ExtendedScriptException:
org.mozilla.javascript.EcmaError: TypeError: Cannot find function
substring. (Unknown Source#25) in Unknown Source at line number 25

Are the basic JavaScript functions not available?

Thanks.


On Thu, May 29, 2014 at 3:43 PM, Ishan Jayawardena-2 [via WSO2 Oxygen Tank]
ml-node+s10903n97415...@n7.nabble.com wrote:

 You can find it in org.apache.synapse.mediators.bsf.ScriptMessageContext.
 Thanks,
 Ishan.


 On Thu, May 29, 2014 at 3:29 PM, Ramindu Deshapriya [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=97415i=0
  wrote:

 Hi,

 I am having trouble finding the functions available to the JavaScript API
 when used within a Script Mediator in the ESB. Could someone please direct
 me to a list of functions which are available for use within a Script
 Mediator?

 Thanks.



 --
 View this message in context:
 http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411.html
 Sent from the WSO2 Development mailing list archive at Nabble.com.
 ___
 Dev mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=97415i=1
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Ishan Jayawardena
 Senior Software Engineer
 Mobile: +94 (77) 408 2330

 ___
 Dev mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=97415i=2
 http://wso2.org/cgi-bin/mailman/listinfo/dev


 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411p97415.html
  To start a new topic under WSO2 Development, email
 ml-node+s10903n3...@n7.nabble.com
 To unsubscribe from WSO2 Development, click 
 herehttp://wso2-oxygen-tank.10903.n7.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3code=cmFzYWRlODhAZ21haWwuY29tfDN8LTEwNDAzODU2MTk=
 .
 NAMLhttp://wso2-oxygen-tank.10903.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml




-- 
Au revoir!
Ramindu Deshapriya.

Member - Sahana Software Foundation http://sahanafoundation.org
http://rdeshapriya.com

http://www.facebook.com/rdeshapriya   http://twitter.com/#%21/rami_desh
https://plus.google.com/113801459480978566130
http://www.linkedin.com/profile/view?id=84017607trk=tab_pro
http://rdeshapriya.com http://lmakuthan.blogspot.com




--
View this message in context: 
http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-JavaScript-API-for-Script-mediator-tp97411p97416.html
Sent from the WSO2 Development mailing list archive at Nabble.com.___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev