# Accessing SOAP::Mapping::Object

**URL:** <https://www.ruby-forum.com/t/accessing-soap-object/111963>\
**Category:** Ruby\
**Created:** [August 13, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/accessing-soap-object/111963 "2007-08-13T22:18:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![learningruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6bbea6/32.png) [@learningruby](https://www.ruby-forum.com/u/learningruby)\
**Post date:** [August 13, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/accessing-soap-object/111963/1 "2007-08-13T22:18:03Z")

</div>

Hi,

I just started with SOAP and Ruby and after one day trying to get it  
working I’am now stuck at getting the response into useable variables  
i.e. accessing the SOAP::Mapping::Object.  
I used soap4r and wdsl2ruby for generating the client code

The bare SOAP XML result is:

\<?xml version="1.0" encoding="utf-8"?\>

\<soap:Envelope xmlns:soap=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”  
xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)”\>  
soap:Body  
  
  
  
EF000000AC023F282007-07-24 19:08:58\</  
LastConnect\>  
2007-07-23 10:34:48  
2007-07-24 15:51:34  
2007-07-24 20:31:31  
2007-07-23 10:05:14  
2007-07-24 19:09:03  
27  
0  
23  
0  
  
  
  
  
\</soap:Body\>  
\</soap:Envelope\>

In ruby  
— begin ruby code ------  
#!/usr/bin/env ruby -d

# issue the command to the server

endpoint\_url = ARGV.shift  
obj = DefaultSoap.new(endpoint\_url)

# run ruby with -d to see SOAP wiredumps.

obj.wiredump\_dev = STDERR if $DEBUG

# 

SoapResponse = obj.fetchKnownUnits(:username =\> ‘Me’, :challenge =\>  
‘Secret’)

pp SoapResponse

----- end ruby code ----

The result on screen is:

#\<FetchKnownUnitsResponse:0x102389c  
@fetchKnownUnitsResult=  
#\<SOAP::Mapping::Object:0x8119ce {}Units=#\<SOAP::Mapping::Object:  
0x81191a {}Unit=#\<SOAP::Mapping::Object:0x811802  
{}Id=“EF000000AC023F28” {}LastConnect=“2007-07-24  
19:08:58” {}LastClear=“2007-07-23  
10:34:48” {}LastDisconnect=“2007-07-24  
15:51:34” {}LastRTCValue=“2007-07-24  
20:31:31” {}LastLogStart=“2007-07-23  
10:05:14” {}LastLocalTime=“2007-07-24  
19:09:03” {}LastRecordCount=“27” {}LastVersion=“0” {}LastRevision=“23”  
{}LastErrorStatus=“0”\>\>\>\>

Can someone please give the code to capture the value foe the unit Id  
into a variable.

I expected it to be something like:  
my\_unit\_id = SoapResponse[‘fetchKnownUnitsResult’][‘Units’][0][‘Id’]

Thanx

Patrick

---

<div class="post-metadata">

**Author:** ![learningruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6bbea6/32.png) [@learningruby](https://www.ruby-forum.com/u/learningruby)\
**Post date:** [August 13, 2007, 10:36pm UTC](https://www.ruby-forum.com/t/accessing-soap-object/111963/2 "2007-08-13T22:36:06Z")

</div>

On Aug 13, 10:14 pm, Ruby R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”  
> 2007-07-24 20:31:31  
> \</soap:Body\>  
> obj.wiredump\_dev = STDERR if $DEBUG  
> #\<FetchKnownUnitsResponse:0x102389c
> 
> Can someone please give the code to capture the value foe the unit Id  
> into a variable.
> 
> I expected it to be something like:  
> my\_unit\_id = SoapResponse[‘fetchKnownUnitsResult’][‘Units’][0][‘Id’]
> 
> Thanx
> 
> Patrick

You should send your question to [http://groups.google.com/group/soap4r](http://groups.google.com/group/soap4r)

---

<div class="post-metadata">

**Author:** ![learningruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6bbea6/32.png) [@learningruby](https://www.ruby-forum.com/u/learningruby)\
**Post date:** [August 14, 2007, 10:21am UTC](https://www.ruby-forum.com/t/accessing-soap-object/111963/3 "2007-08-14T10:21:12Z")

</div>

On 13 aug, 22:30, dima [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > EF000000AC023F282007-07-24 19:08:58\</  
> >   
> > endpoint\_url = ARGV.shift  
> > ----- end ruby code ----  
> > 15:51:34" {}LastRTCValue="2007-07-24  
> > Thanx
> 
> > Patrick
> 
> You should send your question tohttp://groups.google.com/group/soap4r

I just did, thank you
