Topic: Issues handling SavonRB SOAP Response (hash)

I have a webservice I query for search results (let's assume I'm querying Google's web service or example).  In my query, I could ask for 1 or more results.  When I ask for 1 result, I transform the SavonRB answer to a hash and get the "title" like this [:field1][:field2][:field3][:field4][:title]

- My helper

def wssearch (param1)
wsanswer = @soap_client.request :sear, "PerformQuery" do
soap.body = { Body I send to the WS with my #{param1}} 
@wsanswerhash = wsanswer.to_hash[:field1][:field2][:field3][:field4][:title]

- My view

<% wssearch( "query" ) %>
<%= @wsanswerhash %>

When I only ask for 1 result (in my WS query), it works and I get my title.  When I ask for more than 1 result (in my WS query), I get the "can't convert Symbol into Integer" error for the line  <% wssearch( "query" ) %>

Here are the SOAP answers

When I ask for 1 result

{:field1=>{:field2=>{:field5=>true, :field6=>"@uri", :field3=>{:field7=>{:field8=>"value1", :title=>"TheTitle1", :field9=>"blabla1", }}, :exception_code=>"1", :exception_context=>nil}, :@xmlns=>""}}

When I ask for 2 results (Notice the extra [ ] )

{:field1=>{:field2=>{:field5=>true, :field6=>"@uri", :field3=>{:field7=>[{:field8=>"Value1", :title=>"TheTitle1", :field9=>"blabla1" }, {:field8=>"value2", :title=>"TheTitle2", :field9=>"blabla2"]}, :exception_code=>"1", :exception_context=>nil}, :@xmlns=>""}}

Same but presented differently

{:field5=>true, :field6=>"@uri", :field3=>
{:field8=>"value1", :title=>"TheTitle1", :field9=>"blabla1"}}, 
:exception_code=>"1", :exception_context=>nil}, :@xmlns=>""}}
{:field5=>true, :field6=>"@uri", :field3=>
{:field8=>"Value1", :title=>"TheTitle1", :field9=>"blabla1"}, 
{:field8=>"value2", :title=>"TheTitle2", :field9=>"blabla2"]}, 
:exception_code=>"1", :exception_context=>nil}, :@xmlns=>""}}

How could I get it to work - I mean asking for more than 1 result and get only the field I want from all the results ?

Thanks !

Last edited by badabing_can (2012-02-29 14:38:30)