views:

562

answers:

4

Hey guys, I am trying to call a java soap webservice within my ruby on rails app. Therefor I use the following code:

email = "[email protected]"
pw = "legendary"
XSD::Charset.encoding = 'UTF8'
wsdlfile = "http://134.60.60.40:8080/FuturecanteenWebservice/DatabaseWSService?wsdl"
driver = SOAP::WSDLDriverFactory.new(wsdlfile).create_rpc_driver
driver.connectDB
@result = driver.checkUserForLogin(email, pw)

but when I run the action above I am always getting wrong number of arguments for any kind of method of the webservice I try to use.

Can anybody help me with this one?

Cheers for any help.

+2  A: 

First off, Ruby's SOAP is just terrible. It is slightly better if you use the gem version of soap4r, but still just awful.

What does the WSDL look like for the checkUserForLogin method. Are the arguments named? (if so, specify them like checkUserForLogin(:email => email, :pw => pw) )

Ben Hughes
A: 

Thanks for the answer. Actually the checkUserForLogin seems to work now. But I have a method connectDB which I want to use to set up the connection to my database so that I dont have to put this in each method. It does not expect any arguments and I tried calling it like driver.connectDB and like driver.connectDB(), but neither worked. I always get the exception wrong number of arguments 0 for 1.

A: 

Now I tried calling the connectDB passing nil as an argument and it seems to work?! Really weird. Maybe anyone knows whats going on here. Thanks for any help!!!

A: 

Allright seems to work now. But when I debug my result I get some kind of soap objects. How can I cast those back in arrays or whatever it is?

#<SOAP::Mapping::Object:0x324f470 {}return=[#<SOAP::Mapping::Object:0x324eda4>, #<SOAP::Mapping::Object:0x324e0b6>, #<SOAP::Mapping::Object:0x324dd46>, #<SOAP::Mapping::Object:0x324da4e>, #<SOAP::Mapping::Object:0x324d6d4>, #<SOAP::Mapping::Object:0x324d3be>, #<SOAP::Mapping::Object:0x324d076>]>  #<SOAP::Mapping::Object:0x3259c36 {}return="true">  #<SOAP::Mapping::Object:0x3255e7e {}return="false">