Hi!
I try to use a layered webservice and I want to get back an array of
users;
In the API I use:
api_method :listUsers,:returns=>[[User]]
in the service:
def listUsers
User.find(:all)
end
Result in soap mode:
Don’t know how to cast TrueClass to Object
Result in XML-RPC mode:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.collect
It’s work on another machine. (Here is windows)
I tried to create another ampty project with Only this model, and only
one controller.
In controller used this code (the model is the default generated):
class UserAdminAPI < ActionWebService::API::Base
api_method :listUsers,:returns=>[[User]]
end
class UserAdminService < ActionWebService::Base
web_service_api UserAdminAPI
def listUsers
User.find(:all)
end
end
class AdminController < ApplicationController
wsdl_service_name ‘Admin’
web_service_dispatching_mode :delegated
web_service_scaffold :invoke
web_service(:user) { UserAdminService.new }
end
What’s the problem? (If I change the return variable to :string and I in
the implementation I use YAML.dump User.find(:all). It’s get back the
value.
the flul log: http://www.rafb.net/paste/results/PNmYct37.html
Cow
Yeah, I have a very similar problem. I want my webservice to return say
a Person object, but when I invoke the method through SOAP I get “Don’t
know how to cast FalseClass to Object”, and through XML-RPC I get a
whiney NULL error.
I have used the exact example from the Agile Rails book … have you
managed to solve your problem yet?
Joerg
P.S. It all works fine if my methods return integers or strings.
Háber János wrote:
Hi!
I try to use a layered webservice and I want to get back an array of
users;
In the API I use:
api_method :listUsers,:returns=>[[User]]
in the service:
def listUsers
User.find(:all)
end
Result in soap mode:
Don’t know how to cast TrueClass to Object
Result in XML-RPC mode:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.collect
It’s work on another machine. (Here is windows)
I tried to create another ampty project with Only this model, and only
one controller.
In controller used this code (the model is the default generated):
class UserAdminAPI < ActionWebService::API::Base
api_method :listUsers,:returns=>[[User]]
end
class UserAdminService < ActionWebService::Base
web_service_api UserAdminAPI
def listUsers
User.find(:all)
end
end
class AdminController < ApplicationController
wsdl_service_name ‘Admin’
web_service_dispatching_mode :delegated
web_service_scaffold :invoke
web_service(:user) { UserAdminService.new }
end
What’s the problem? (If I change the return variable to :string and I in
the implementation I use YAML.dump User.find(:all). It’s get back the
value.
the flul log: http://www.rafb.net/paste/results/PNmYct37.html
Cow
Hi!
I think you are use postgresql or other database which have real boolean
type (mysql boolean type is an alias to int(1)). And the Webservice
can’t cast this type to primitive.
Cow
Joerg D. Ãrta:
I am using MySql, and don’t have any booleans either … but I’ll see if
it can have anything to do with my table columns. But at the moment
(well, the past few days) it looks like a bug to me in Rails.
Hi!
I think the deleted is the problem. Rails automatically convert the
“deleted” field to boolean. because WS can’t convert boolean to Object
so you can get the TrueClass can’t convert error.
http://wiki.rubyonrails.com/rails/pages/HowtoUseBooleanColumns
So the Rails is buggy…
Cow
Joerg D. Ãrta:
Right. If I return a User object from my AWS, everything is cool when I
use XML-RPC (SOAP gives me an error: Cannot map User to SOAP/OM.).
However, if I return a Brand object from my AWS, I get the errors
mentioned in the first email of this thread.
I can’t see a difference though in these tables that would cause this
differing behaviour. I have added a tinyint(1) and a text field to User,
and it still works with those fields.
Perhaps I am using field names that I shouldn’t?
CREATE TABLE users
(
id
int(11) unsigned NOT NULL auto_increment,
type
varchar(20) default NULL,
username
varchar(50) NOT NULL default ‘’,
name
varchar(50) NOT NULL default ‘’,
parent_id
int(11) default NULL,
email
varchar(100) NOT NULL default ‘’,
updated_on
datetime default NULL,
created_on
datetime default NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE brands
(
id
int(11) unsigned NOT NULL auto_increment,
name
varchar(100) NOT NULL default ‘’,
abbreviation
varchar(11) NOT NULL default ‘’,
description
text NOT NULL,
image
varchar(100) default NULL,
image_timestamp
datetime default NULL,
position
int(11) default NULL,
deleted
tinyint(1) NOT NULL default ‘0’,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Yeah that was it. Thanks.