Index: [Article Count Order] [Thread]

Date:  Fri, 22 Mar 2002 18:47:55 +0900
From:  "NAKAMURA, Hiroshi" <nahi@keynauts.com>
Subject:  [webricken:75] Re: soaplet confusion saga
To:  <webricken@notwork.org>
Message-Id:  <000801c1d186$a478af40$85222fc0@sarion.co.jp>
In-Reply-To:  <20020322093159.WWRU14382.mta4-rme.xtra.co.nz@there>
X-Mail-Count: 00075

Hi, Holden,

I'm sorry but I misunderstood the problem.

> From: Holden Glova [mailto:dsafari@xtra.co.nz] 
> Sent: Friday, March 22, 2002 6:37 PM

> > Hmm.  Instance of Proxy is created by SOAP4R unmarshaller,
> > isn't it?  The SOAP4R unmarshaller allocates new object
> > without calling user's initialize and set its instance
> > variables.  Your Proxy#initialize is not called.  So the
> > method 'name' is not on your method list.
> 
> Not sure I fully understand - my proxy initialize method must 
> be getting 
> called because the correct data is stored in the name 
> attribute. Also, when I 
> do a #type#to_s on the object coming back it is of type 
> RAA::Proxy which is 
> my class, no?

Yes.  But if the object was created by SOAP4R,
your Proxy#initialize was not called.  SOAP4R set
@name using instance_eval.

Is the Proxy object really sent back from the server side?
Your server side method is something like

  def search_for_entry_index
    proxy = RAA::Proxy.new( [ :name ] )
    proxy.name = [ "name1", "name2" ... ]
    return proxy
  end

no? ... (*)

> > Workaround: you can retrieve instance variables like;
> > name = obj.instance_eval { @name }
> >
> > Other solutions:
> >
> > 1. SOAP4R creates proxy object when it encount unknown
> >   klass.  Remove Proxy class definition then your code will
> >   work.
> 
> I'll try this right away.

Seeing the result of inspect, it should work but it's only a workaround.

> > 2. Can you send back Hash instead of Proxy class from
> >   server?
> 
> I'm currently sending back an Array, would that do a similar 
> thing to the 
> Hash suggestion?

Ignore this if above (*) is wrong.
I thought you should define

  def search_for_entry_index
    hash = Hash.new
    hash[ 'name' ] = [ "name1", "name2" ... ]
    return proxy
  end

instead of returning Proxy object.

> > 3. Can you send back explicitly typed object?
> 
> Hmm..Not sure how I would do that? Is there examples of how 
> to do that 
> somewhere? This is more then likely due to my lack of 
> understanding about 
> SOAP, but hey - that is why I'm playing with it :)

I'll do it after I will understand what you want to do
correctly.

> /me goes and tries changing the name to see if it makes a diference

Thanks in advance.  I remembered that I introduced the
bug which is a name crash of the method "name" in an old
release of SOAP4R...  There may be the same beast in the
code.

Regards,
// NaHi