Bhatt Thanks for the feedback. Can you post a sample? It would make a great addition to our list of samples.
Paul On Jan 30, 2008 4:23 PM, bhatt <[EMAIL PROTECTED]> wrote: > > Many Thanks Paul and Asankha for helping me. I am able to run an inline > groovy script in Synapse now. > Groovy and Synapse make a deadly combination for sure. No need of hardcoded > java dblookup mediator for me now. > > -Bhatt > > > > pzfreo wrote: > > > > You might also like to check out the video of a presentation I made about > > it: > > > > http://www.theserverside.com/news/thread.tss?thread_id=47757 > > > > Paul > > > > On Jan 24, 2008 3:52 PM, Asankha C. Perera <[EMAIL PROTECTED]> wrote: > >> Hi Bhatt > >> > I am using synapse 1.1 binary distribution and want to use groovy > >> script to > >> > mediate. I couldn't find any example in this distribution on groovy > >> mediation. > >> > > >> Yes, but since Groovy is an Apache BSF scripting language, it gets > >> automatically supported by Synapse. So all you have to do is write your > >> script and make it available to a script mediator. You have to point to > >> an external script or specify it in-line, and also tell synapse which > >> type of script it is.. > >> > 1. Which synapse distribution has groovy examples ("hello world" etc) / > >> > support? > >> > > >> > 2. Should I compile "service.groovy" to bytecode and put somewhere in > >> > synapse? > >> > > >> Here is a sample Groovy in-line script I used recently to create a HTTP > >> basic authentication header... > >> > >> <syn:script language="groovy">byte[] username = > >> mc.getProperty("username").getBytes(); > >> byte[] password = mc.getProperty("password").getBytes(); > >> byte[] authString = new byte[username.length + password.length + 1]; > >> System.arraycopy(username, 0, authString, 0, username.length); > >> authString[username.length] = (byte) ':'; > >> System.arraycopy(password, 0, authString, username.length+1, > >> password.length); > >> mc.setProperty("Authorization", "Basic " + > >> org.apache.axiom.om.util.Base64.encode(authString));</syn:script> > >> > >> > 3. Referring to the folowing link > >> > > >> http://wso2.org/project/esb/java/1.0/docs/ESB_Samples.html#ExtensionMediators > >> > I tried to add the following lines in an existing sample > >> > > >> > <localEntry key="groovyScript" > >> > src="file:repository/conf/sample/resources/script/service.groovy"/> > >> > <script language="groovy" key="groovyScript"/> > >> > > >> > where service.groovy has the following lines: > >> > def name='World'; println "Hello $name!" > >> > > >> > Now I tried to start a synapse configuration and I got the following > >> > exception: > >> > > >> > ....... > >> > ....... > >> > 2008-01-24 20:40:17,811 [10.140.15.208-petris-chandra] [main] INFO > >> > XMLConfigurationBuilder Generating the Synapse configuration model by > >> parsing the XML > >> > ....... > >> > ....... > >> > > >> > Please help me so that groovy script can mediate. > >> > > >> Wrap the actual [external] Groovy script as any XML as follows: (Refer > >> Sample # 350 > >> http://ws.apache.org/synapse/Synapse_Samples.html#ScriptMediator) > >> > >> <x><![CDATA[ > >> def name='World'; println "Hello $name!" > >> ]]></x> > >> > >> asankha > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > > > -- > > Paul Fremantle > > Co-Founder and VP of Technical Sales, WSO2 > > OASIS WS-RX TC Co-chair > > > > blog: http://pzf.fremantle.org > > [EMAIL PROTECTED] > > > > "Oxygenating the Web Service Platform", www.wso2.com > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > -- > View this message in context: > http://www.nabble.com/how-to-use-groovy-script-to-mediate-in-synapse-tp15066002p15184531.html > Sent from the Synapse - Dev mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Paul Fremantle Co-Founder and VP of Technical Sales, WSO2 OASIS WS-RX TC Co-chair blog: http://pzf.fremantle.org [EMAIL PROTECTED] "Oxygenating the Web Service Platform", www.wso2.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
