Web Services and Ruby

I poked around in the google archives and I didn’t get any really
good answers. I know you can do SOAP with ruby, but has anyone
poked around with the WSDL stuff yet?

On a slightly different vein, is there any consensus on how to
offer WSDL/SOAP services using Ruby as the programming
environment?

  • From my brief examination it seems like there are no good useful
    WSDL tools yet, the best automation I’ve seen so far is a tool
    to write a Java skeleton from the WSDL… Seem exactly
    bass-ackwards to me. I want the WSDL generated from the code.

I’m trapped in Grid Computing FLA[1] hell and I need a
lifeline…

_ Booker C. Bense

[1]- or TLA++

bbense+comp.lang.ruby.May.22.03@telemark.slac.stanford.edu wrote in
message news:baj4dk$m6b$1@news.Stanford.EDU…

-----BEGIN PGP SIGNED MESSAGE-----

I poked around in the google archives and I didn’t get any really
good answers. I know you can do SOAP with ruby, but has anyone
poked around with the WSDL stuff yet?

I think someone were doing something, but I don’t think it got released.

Anyway, I just discovered the akronym WSIF
http://ws.apache.org/wsif/

protocol independent web services

Mikkel

Soap4R has an initial automated wsdl driver factory,
But in my experience it fails because misses XML/Schema (at least,
all the schema syuff I found in xmethods.org
Possibly we don’t have a XMLschema 2001 parser at all in ruby ?

···

il Thu, 22 May 2003 18:20:36 +0000 (UTC), bbense+comp.lang.ruby.May.22.03@telemark.slac.stanford.edu ha scritto::

-----BEGIN PGP SIGNED MESSAGE-----

I poked around in the google archives and I didn’t get any really
good answers. I know you can do SOAP with ruby, but has anyone
poked around with the WSDL stuff yet?

Looked into this myself several years ago. A main issue is that since
Ruby is dynamically typed, method signatures don’t have type metadata
on them to allow automatic generation of WSDL method invocation
signatures.

If you have a class with the following method (silly example):

class Person
def set_name(first, last)
@first = first
@last = last
end

def get_name
@first+" "+@last
end
end

What is the ‘type’ of first and last or the return type of get_name?
These are likely Strings so the type of “xsd:string” but where do you
place this metadata to allow the generation of a WSDL definition from
an instance of Person? In Java, these parameters are typed so (using
reflection) you can get that type and generate the WSDL definition
automagically. In Ruby, you either need to annotate the class or have a
separate object that holds the type metadata for WSDL generation:

class Person
def set_name(first, last)
@first = first
@last = last
nil
end
def_types :set_name, :first=>‘xsd:string’, :last=>‘xsd:string’

def get_name
@first+" "+@last
end
def_types :get_name, :_return=>‘xsd:string’
end

Where def_types is a method that places metadata on the class object
for the defined methods…or something like:

ws = WebService.new(Person)
ws.add_method :set_name, :first=>‘xsd:string’, :last=>‘xsd:string’
ws.add_method :get_name, :_return=>‘xsd:string’

Where you have a WebService class that holds the metadata itself. I
wrote such a class a bit ago but never finished it…if there is
interest I could spend a bit of time on it and release it to NiHi for
(optional) inclusion with SOAP4R…let me know.

-rich

···

On Thursday, May 22, 2003, at 02:43 PM, bbense+comp.lang.ruby.May.22.03@telemark.slac.stanford.edu wrote:

On a slightly different vein, is there any consensus on how to
offer WSDL/SOAP services using Ruby as the programming
environment?

  • From my brief examination it seems like there are no good useful
    WSDL tools yet, the best automation I’ve seen so far is a tool
    to write a Java skeleton from the WSDL… Seem exactly
    bass-ackwards to me. I want the WSDL generated from the code.

Hi, gabriele,

From: gabriele renzi [mailto:surrender_it@rc1.vip.lng.yahoo.com]
Sent: Friday, May 23, 2003 6:24 AM

il Thu, 22 May 2003 18:20:36 +0000 (UTC),
bbense+comp.lang.ruby.May.22.03@telemark.slac.stanford.edu ha
scritto::

-----BEGIN PGP SIGNED MESSAGE-----

I poked around in the google archives and I didn’t get any really
good answers. I know you can do SOAP with ruby, but has anyone
poked around with the WSDL stuff yet?

Soap4R has an initial automated wsdl driver factory,
But in my experience it fails because misses XML/Schema (at least,
all the schema syuff I found in xmethods.org

Oops. Are errors caused from ‘<document …>’ element?
It should be fixed in CVS version but I’ve still not been
able to take a time to release soap4r/1.5.0…

Current soap4r CVS version requires the latest version of
http-access2 which is only on CVS. I’ll release the new
versions at the same time.

Possibly we don’t have a XMLschema 2001 parser at all in ruby ?

=> true

Regards,
// NaHi

Richard Kilmer wrote:

In Ruby, you either need to annotate the class or have a
separate object that holds the type metadata for WSDL generation:

class Person
def set_name(first, last)
@first = first
@last = last
nil
end
def_types :set_name, :first=>‘xsd:string’, :last=>‘xsd:string’

def get_name
@first+" "+@last
end
def_types :get_name, :_return=>‘xsd:string’
end

This is why I’d like ‘def’ to return the UnboundMethod object. This
would let us write

 externally_typed(nil, String, String) def set_name(first, last)
    @first = first
    @last = last
    nil
 end

 externally_typed(String) def get_name
   @first + " " + @last
 end

(where String might also be “xsd:string” or whatever)

It would also be nice if method reflection gave us the names of the
parameters, but that’s not strictly necessary to get this scheme off the
ground.

Cheers

Dave

“Richard Kilmer” rich@infoether.com wrote in message
news:604BD5FC-8F8D-11D7-837D-000A95765742@infoether.com

What is the ‘type’ of first and last or the return type of get_name?
These are likely Strings so the type of “xsd:string” but where do you
place this metadata to allow the generation of a WSDL definition from
an instance of Person?

This may be the only good argument for Hungarian naming convention:

class Person
def set_name(first, last)
@strFirst = first
@strLast = last
nil
end

You could use this idea with a different naming convention:

@first_xsd_str

def_types :set_name, :first=>‘xsd:string’, :last=>‘xsd:string’

This will eventually get out of sync (Don’t Repeat Yourself), but it does
make it easy to carry type information around.
Thus you could have xsd interface as a ruby module you included.
The you are not using the class as a definition, but simply exposing a
known interface, which is not a repeat yourself issue
but rather a lack of interface compliance if something goes wrong (as if we
care why the program breaks down…).

Mikkel

Hi, gabriele,

From: gabriele renzi [mailto:surrender_it@rc1.vip.lng.yahoo.com]
Sent: Friday, May 23, 2003 6:24 AM

il Thu, 22 May 2003 18:20:36 +0000 (UTC),

Oops. Are errors caused from ‘<document …>’ element?

this try is on winXP, PragPérog’s ruby 1.6.8, but I don’t know the
version of soap4r…

require ‘soap/wsdlDriver’
=> true

?>
?> _WSDL = ‘http://www.xmethods.net/sd/2001/BabelFishService.wsdl
=> “http://www.xmethods.net/sd/2001/BabelFishService.wsdl

?> babel = SOAP::WSDLDriverFactory.new(_WSDL).createDriver
WSDL::WSDLParser::UnknownElementError: Unknown
element{http://schemas.xmlsoap.org/wsdl/}documentation.

    from

C:/Programmi/ruby/lib/ruby/site_ruby/1.6/wsdl/parser.rb:166:in
`decodeTag’

It should be fixed in CVS version but I’ve still not been
able to take a time to release soap4r/1.5.0…

I’ll wait :slight_smile:

Current soap4r CVS version requires the latest version of
http-access2 which is only on CVS. I’ll release the new
versions at the same time.

I think I asked this once, but repetita iuvant: what http-access does?
Why soap4r can’t use net/http?
(just trying to understand :slight_smile:

Possibly we don’t have a XMLschema 2001 parser at all in ruby ?

=> true

doh!

thanks anyway for you great work :slight_smile:

···

il Fri, 23 May 2003 10:27:28 +0900, “NAKAMURA, Hiroshi” nahi@keynauts.com ha scritto::

Hi,

From: gabriele renzi [mailto:surrender_it@rc1.vip.lng.yahoo.com]
Sent: Saturday, May 24, 2003 10:29 AM

this try is on winXP, PragPérog’s ruby 1.6.8,
but I don’t know the version of soap4r…

Maybe 1.4.8.1, the newest release.
Sorry for your inconvenience.

WSDL::WSDLParser::UnknownElementError: Unknown
element{http://schemas.xmlsoap.org/wsdl/}documentation.

    from

C:/Programmi/ruby/lib/ruby/site_ruby/1.6/wsdl/parser.rb:166:in
`decodeTag’

wsdl4r should ignore documentation elements.

Current soap4r CVS version requires the latest version of
http-access2 which is only on CVS. I’ll release the new
versions at the same time.

I think I asked this once, but repetita iuvant:

I didn’t have enough time to read ruby-talk/comp.lang.ruby
messages in a few months. Sorry for not responding about it.

what http-access does?

There’s little advantage about functionality.

  • http-access2 handles HTTP/1.1 persistent connection to a
    site instead of you.
  • MT-safe (I hope :slight_smile:
  • streaming POST through IO.

You can implement above functions with net/http easilly.

The reason I don’t use net/http is;

  • I already had my implementation before net/http.
  • I want to keep controllable/readable implementation for
    my testing platform. I once read and tried to hack
    net/* but I couldn’t.

As a HTTP testing platform, I use WEBrick as a server side
and http-access2 as a client side.

Why soap4r can’t use net/http?
(just trying to understand :slight_smile:

For my omission. I must write the new streamHandler.rb
with net/http some day, but the SOAP client which use this
will be MT-unsafe (It’s not a serious problem; Users
instanciate SOAP client per thread).

Regards,
// NaHi