# Xml-rpc client result

**URL:** <https://www.ruby-forum.com/t/xml-rpc-client-result/123800>\
**Category:** Ruby\
**Created:** [December 20, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800 "2007-12-20T19:04:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [December 20, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800/1 "2007-12-20T19:04:03Z")

</div>

I posted this on Nabble but don’t think it made it through to the  
list. Here’s the q:

I can use the xmlrpc library to call a remote Web Service, but the  
results appear always to be returned as an XML stream. The code  
implies that the xml is parsed, and doing some messing with it in irb  
shows that at some level, the result value can be treated as a hash.  
I’m unable to determine to what extent. Consider a result such as:

How do I get this into a parsed form such as a hash or array or  
arrays? Or more correctly, what is the best way of iterating this data?

Thanks

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [December 20, 2007, 7:32pm UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800/2 "2007-12-20T19:32:44Z")

</div>

On Dec 20, 2007, at 12:03 PM, s.ross wrote:

> I can use the xmlrpc library to call a remote Web Service, but the  
> results appear always to be returned as an XML stream.

> 

This is not a valid XML-RPC response. You can read the spec at:

[http://www.xmlrpc.com/spec](http://www.xmlrpc.com/spec)

Looks like you are dealing with a custom protocol here.

James Edward G. II

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [December 20, 2007, 8:13pm UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800/3 "2007-12-20T20:13:46Z")

</div>

On Dec 20, 2007, at 10:31 AM, James G. wrote:

> > 
> 
> This is not a valid XML-RPC response. You can read the spec at:
> 
> [http://www.xmlrpc.com/spec](http://www.xmlrpc.com/spec)
> 
> Looks like you are dealing with a custom protocol here.
> 
> James Edward G. II

Well, I abbreviated the actual XML. Really:

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

I’m looking at a ruby-debug dump of “data” from the call,  
parser().parseMethodResponse(data). I think it’s valid XML-RPC. Sorry  
for the misleading trimming of the response.

Thx

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [December 20, 2007, 11:58pm UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800/4 "2007-12-20T23:58:37Z")

</div>

As a followup, I can parse the returned XML string using XmlSimple,  
which works ok. I just thought the parsing took place automagically in  
the XMLRPC parser.

–s

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [December 21, 2007, 12:36am UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800/5 "2007-12-21T00:36:05Z")

</div>

On Dec 20, 2007, at 3:05 PM, James G. wrote:

> XML-RPC is just giving you what the XML said it received, a String.
> 
> James Edward G. II

No, forgive me for the sort of vague question. The Web Service  
provider made me sign a contract not to blah, blah, blah… so I felt  
I should obfuscate a certain amount of this XML response. This is the  
actual XML with the service provider and member names changed to  
protect the guilty. Again, when the string is returned, punching it  
into XmlSimple allows me access to each member of the image  
collection. However, it would be simpler to stay with one library if  
possible.

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

By the way, is there a better way to get this raw data than in ruby-  
debug?

Thanks again,

–s

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [December 21, 2007, 3:40am UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800/6 "2007-12-21T03:40:53Z")

</div>

On Dec 20, 2007, at 5:35 PM, s.ross wrote:

> > please show the full response, as you receive it? If those item  
> > codes are returned inside of the … tags you  
> > showed earlier, XML-RPC is just giving you what the XML said it  
> > received, a String.
> > 
> > James Edward G. II
> 
> No, forgive me for the sort of vague question.

No worries. I get it now.

> 777 Building""/\>

Yeah, that’s an odd use of XML-RPC structures. Instead of passing you  
an Array of Structs, which a library could completely extract, they  
give you a custom XML protocol inside a normal String. Sad really as  
they clearly don’t understand the point of XML-RPC.

There’s no getting around it, you’ll need to make a second XML parsing  
pass as you have mentioned doing.

> By the way, is there a better way to get this raw data than in ruby-  
> debug?

I’m not aware of an easy way to get the data, no.

James Edward G. II

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [December 21, 2007, 5:22am UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800/7 "2007-12-21T05:22:00Z")

</div>

On Dec 20, 2007, at 6:40 PM, James G. wrote:

> Yeah, that’s an odd use of XML-RPC structures. Instead of passing  
> you an Array of Structs, which a library could completely extract,  
> they give you a custom XML protocol inside a normal String. Sad  
> really as they clearly don’t understand the point of XML-RPC.

Thanks so much for your help. At least I’m getting the data.

–s

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [December 21, 2007, 12:06am UTC](https://www.ruby-forum.com/t/xml-rpc-client-result/123800/8 "2007-12-21T00:06:13Z")

</div>

On Dec 20, 2007, at 4:58 PM, s.ross wrote:

> As a followup, I can parse the returned XML string using XmlSimple,  
> which works ok. I just thought the parsing took place automagically  
> in the XMLRPC parser.

OK, forgive me for not getting this, but you’ve shown us two pieces of  
XML. One look XML-RPCish, but the other did not. Can you please show  
the full response, as you receive it? If those item codes are  
returned inside of the … tags you showed earlier,  
XML-RPC is just giving you what the XML said it received, a String.

James Edward G. II
