[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

transfer (own)ruby object over SOAP

Philipp

8/28/2007 10:29:00 AM

Hello everyone,
after 2 days searching the web for a solution i get stuck.

I have a rails APP with a SOAP interface and a simply ruby client
e.g
I have a object CAR that has a name and 4 DOORS

CAR <-1:N-> DOOR

//structure looks something like this
class car {
id
name
}

class door{
id
car_id
}


now i want to transfer a instance of the object car over soap to the
client.
SOAP only supports , primary class types like string, int, float and
so on..right ?

now i was thinking about to do it with yaml or marshal, or xml i tried
it the last 2 days but it dint work

# on the rails app i did
config_dump = SOAP::Marshal.dump(cars)

# i did the transfer as a sting over soap

#on client side id did
cars_array = SOAP::Marshal.load(cars_marshal)

but now i have a stange SOAP::Mapping::Object on the client side, is
there a way to get a normal ruby object in this case CAR-object that i
can do for example

car.doors.each{|door|
puts door
}


thanks ahead


regard
Philipp
ICQ #32815376

2 Answers

NAKAMURA, Hiroshi

8/28/2007 1:19:00 PM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

If there's no need for interoperability, you should use Marshal.

Philipp wrote:
> # on the rails app i did
> config_dump = SOAP::Marshal.dump(cars)
>
> # i did the transfer as a sting over soap
>
> #on client side id did
> cars_array = SOAP::Marshal.load(cars_marshal)
>
> but now i have a stange SOAP::Mapping::Object on the client side, is
> there a way to get a normal ruby object in this case CAR-object that i
> can do for example

Above should work. Please make sure you define user defined classes
(Car and Door) on the client side. Marshal requires it, too.

Regards,
// NaHi

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)

iQEVAwUBRtQgbB9L2jg5EEGlAQJNKAf+MWnLc7q/WRndeXU2CYtwZ2iR4qqzLV3g
p2uymZlxkRPFIfS5om04dr01LMkw3urrlZgkzBqwKXocjMo+Er2IIaAmRMkRZtuU
CYMi2NHoQG01sVOWVJwpm5/McC1Eb9tcJTGmck04WAjklMAqLPG1egehfO7/LFYF
/P+uGXIB9fuU4VC/unzykhsFA4upwUO/bYi0EWr8NfgCSQNDy9qzCGUTKCRGmoXc
sYIlE9XI1uvO+xFle5rHcjKEgHZdB3YW5Ue9tfvCMyfSy/F96Nc4L211A5b7AqKp
WwfNL6eWMKzogxXwLGTYQwStHUKB/MkdHReh2SIgkyTzFY9+wzhVxQ==
=6iVw
-----END PGP SIGNATURE-----

Philipp

8/28/2007 7:49:00 PM

0

Hello NaHi,
thanks, for you answer.

I m using SOAP and WSDL right now,
do u know it there is a trick, i dont want to define all the CLASSES
on the client or in the WSDL API struct , is there a opotunity to
(auto)generate a WSDL/CLASS config from the activerecords structur
which is on the server ?

i think it would be also much easier to maintain afterwards if u do
any extensions to on the server side...

thanks ahread

Philipp




On 28 Aug., 15:18, "NAKAMURA, Hiroshi" <nakah...@sarion.co.jp> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> If there's no need for interoperability, you should use Marshal.
>
> Philipp wrote:
> > # on the rails app i did
> > config_dump = SOAP::Marshal.dump(cars)
>
> > # i did the transfer as a sting over soap
>
> > #on client side id did
> > cars_array = SOAP::Marshal.load(cars_marshal)
>
> > but now i have a stange SOAP::Mapping::Object on the client side, is
> > there a way to get a normal ruby object in this case CAR-object that i
> > can do for example
>
> Above should work. Please make sure you define user defined classes
> (Car and Door) on the client side. Marshal requires it, too.
>
> Regards,
> // NaHi
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (Cygwin)
>
> iQEVAwUBRtQgbB9L2jg5EEGlAQJNKAf+MWnLc7q/WRndeXU2CYtwZ2iR4qqzLV3g
> p2uymZlxkRPFIfS5om04dr01LMkw3urrlZgkzBqwKXocjMo+Er2IIaAmRMkRZtuU
> CYMi2NHoQG01sVOWVJwpm5/McC1Eb9tcJTGmck04WAjklMAqLPG1egehfO7/LFYF
> /P+uGXIB9fuU4VC/unzykhsFA4upwUO/bYi0EWr8NfgCSQNDy9qzCGUTKCRGmoXc
> sYIlE9XI1uvO+xFle5rHcjKEgHZdB3YW5Ue9tfvCMyfSy/F96Nc4L211A5b7AqKp
> WwfNL6eWMKzogxXwLGTYQwStHUKB/MkdHReh2SIgkyTzFY9+wzhVxQ==
> =6iVw
> -----END PGP SIGNATURE-----