Forum: Ruby NewB question on data structure ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
98555c34c169a26de3d014b9f0c1e027?d=identicon&s=25 Pradeep S. (psethi2000)
on 2006-06-14 06:45
Hi,

I am trying to parse variables from a simple data structure/class.. I am
using a web service and it returns a data structure. Here is the code:

@result = ws.HelloWorld(nil)
puts @result.inspect # line 15
puts @result.HelloWorldResult  # line 16

#<SOAP::Mapping::Object:0x174c2b4
{http://tempuri.org/}HelloWorldResult="Hello World"> # line 15
rms_wsdl.rb:16: undefined method `HelloWorldResult' for
#<SOAP::Mapping::Object:0x2e98448> (NoMethodError)

I am sure, I am missing something very basic. Any help would be greatly
appreciated.

Thanks in advance.

Prad
98555c34c169a26de3d014b9f0c1e027?d=identicon&s=25 Pradeep S. (psethi2000)
on 2006-06-14 08:19
To Clarify more, How would I get the data "Hello World" out from the
data structure:

> #<SOAP::Mapping::Object:0x174c2b4
> {http://tempuri.org/}HelloWorldResult="Hello World">

Thanks,


Pradeep Sethi wrote:
> Hi,
>
> I am trying to parse variables from a simple data structure/class.. I am
> using a web service and it returns a data structure. Here is the code:
>
> @result = ws.HelloWorld(nil)
> puts @result.inspect # line 15
> puts @result.HelloWorldResult  # line 16
>
> #<SOAP::Mapping::Object:0x174c2b4
> {http://tempuri.org/}HelloWorldResult="Hello World"> # line 15
> rms_wsdl.rb:16: undefined method `HelloWorldResult' for
> #<SOAP::Mapping::Object:0x2e98448> (NoMethodError)
>
> I am sure, I am missing something very basic. Any help would be greatly
> appreciated.
>
> Thanks in advance.
>
> Prad
Logan Capaldo (Guest)
on 2006-06-14 08:44
(Received via mailing list)
On Jun 14, 2006, at 2:19 AM, Pradeep Sethi wrote:

> To Clarify more, How would I get the data "Hello World" out from the
> data structure:
>
>> #<SOAP::Mapping::Object:0x174c2b4
>> {http://tempuri.org/}HelloWorldResult="Hello World">
>
> Thanks,
>
>

Try using p @result.methods to figure out what the method is called.
Either that or show some more code (where the object gets created).
98555c34c169a26de3d014b9f0c1e027?d=identicon&s=25 Pradeep S. (psethi2000)
on 2006-06-14 09:19
Logan Capaldo wrote:
> On Jun 14, 2006, at 2:19 AM, Pradeep Sethi wrote:
>
>> To Clarify more, How would I get the data "Hello World" out from the
>> data structure:
>>
>>> #<SOAP::Mapping::Object:0x174c2b4
>>> {http://tempuri.org/}HelloWorldResult="Hello World">
>>
>> Thanks,
>>
>>
>
> Try using p @result.methods to figure out what the method is called.
> Either that or show some more code (where the object gets created).

Here is the code. I want to get the value returned by the web service,
in this case text "Hello World". see below HelloWorldResult="Hello
World"

Thanks a lot,

-----------

require 'soap/wsdlDriver'

RMS_WSDL =
'http://host.com/webservice1/trackermapper/service1...
ws = SOAP::WSDLDriverFactory.new(RMS_WSDL).create_rpc_driver

puts ws.inspect

@result = ws.HelloWorld(nil)
puts @result.inspect
puts @result.HelloWorldResult

---
and the output is

#<SOAP::Mapping::Object:0x174c2b4
{http://tempuri.org/}HelloWorldResult="Hello World">
rms_wsdl.rb:16: undefined method `HelloWorldResult' for
#<SOAP::Mapping::Object:0x2e98448> (NoMethodError)
Logan Capaldo (Guest)
on 2006-06-14 09:58
(Received via mailing list)
On Jun 14, 2006, at 3:19 AM, Pradeep Sethi wrote:

>>>
>
> @result = ws.HelloWorld(nil)
>
>

After reading the source for SOAP::Mapping::Object my guess is
@result["HelloWorldResult"] will give you what you want
This topic is locked and can not be replied to.