Issues handling the response (n00b question I think...)

Showing 1-2 of 2 messages
Issues handling the response (n00b question I think...) maxa...@gmail.com 2/27/12 10:35 AM
I have a webservice I query for search results (let's assume I'm querying Google's web service).  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}} 
end
@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=>"http://mylink.com/webservice"}}

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=>"http://mylink.com/webservice"}}

Same but presented differently

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

{: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=>"http://mylink.com/webservice"}}

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 !
Re: Issues handling the response (n00b question I think...) maxa...@gmail.com 3/5/12 4:36 PM
I ended up sending the answer to xml and parsing it using hpricot.

Le lundi 27 février 2012 13:35:16 UTC-5, maxa...@gmail.com a écrit :