TOTD #12: Invoking a Java EE 5 Web service endpoint from JRuby
A user asked how to invoke a Java EE 5 Web service from JRuby. This TOTD explains how a simple Metro Web service deployed on GlassFish V2 can be easily invoked from JRuby.
- Create a simple Web service using NetBeans IDE and deploy it on GlassFish V2 following the screencast #ws7.
- Generate the client-side artifacts using
wsimportas shown below:
C:\workarea\samples\jruby\ws>\testbed\glassfish\final\glassfish\bin\wsimport.bat -keep http://localhost:8080/WebApplication32/HelloService?wsdl
parsing WSDL...
generating code...
compiling code... - Set the CLASSPATH in the command prompt as shown below:
C:\workarea\samples\jruby\ws>set CLASSPATH=.;\testbed\glassfish\final\glassfish\lib\webservices-rt.jar;\testbed\glassfish\final\glassfish\lib\endorsed\webservices-api.jar;C:\testbed\glassfish\final\gl
assfish\lib\activation.jar - Use the JRuby code to invoke the Web service endpoint as shown below:
include Java
service = Java::server.HelloService.new();
port = service.getHelloPort();
result = port.sayHello("Duke");
java.lang.System.out.println(result); - Invoke the JRuby code as shown below:
C:\workarea\samples\jruby\ws>\testbed\ruby\jruby-1.0.1\bin\jruby simple.rb
Hello Duke
That's it! Read more about Tooling Options in Metro.
Using Java classes in JRuby explain the issues that you may encounter in invoking Java classes from JRuby.
Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Technorati: totd jruby jrubyonglassfish glassfish netbeans projectmetro webservices
- Login or register to post comments
- Printer-friendly version
- arungupta's blog
- 651 reads





