Ruby and java

Hi, before I begin I would like to apologize for my English because I’m
French ^^

I’m new in Ruby and I wonder if it’s possible to make Ruby and Java
communicate without JRuby ? Or with a JRuby “block” in my Ruby program ?

In fact, I am trying to develop a Java web service and I have to develop
a client for this web service in Ruby. Everything works well for calls
to my Web Service’s methods without parameters, I receive yet a
java.lang.String in answer.
But I have a method that needs a parameter (java.lang.String) and that
doesn’t work: my Web Service receive a ‘null’ value. I tried to use a
library called rjni but I have some problems with the setup (a file is
not found). Does anybody have another simple idea to send my parameter
without changing the rest of my code?

Here is my Ruby code :

wsdl_url =
http://localhost:8080/SOAPWebServiceLabo3/SOAPWebService?wsdl
service=SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver

#Call to the web service
result=service.volsProgrammesAtDay(String.new(jour))

http://rjb.rubyforge.org/

might be interesting to you.
-r

Thank you for your answer ! I downloaded and installed RJB. There’s a
runtime problem for now, it can’t locate the Java VM, yet I have set
LD_LABRARY_PATH environment variable to point the JVM as it was asked. I
keep trying ^^ Thanks a lot !

It finally work but in my program that doesn’t change anything, my web
service receives a null value…
Here’s my code:

require ‘rjb’
Rjb::load(’.’)
@jString = Rjb::import(‘java.lang.String’)
str = @jString.new_with_sig(‘Ljava.lang.String;’, “abcde”)
result = service.volsProgrammesAtDay(str.toString)

If you’re having trouble with the built-in SOAP library, you might take
a
look at Savon:

https://github.com/rubiii/savon

It’s a bit lower level but might give you greater flexibility with the
data
types you send when talking to the service.

On Fri, Jan 27, 2012 at 5:24 AM, Priscilla C.

Thanks a lot :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs