I have a service method that takes a PaymentMethod which can either be a
CreditCard or a PayPal account.  When I request the service and pass one
or the other it always comes over as a PaymentMethod; the service
doesn't seem to know that the parameter is really a CreditCard or
PayPal.  Here's some sample code that illustrates what I'm talking about
more concretely:

class PaymentsApi < ActionWebService::API::Base
 api_method(
   :create_payment,
   :expects => [
     { :payment_method => PaymentMethod }
   ],
   :returns => [ :payment_id => :string ]
 )
end

class PaymentMethod < ActionWebService::Struct
 # ...
end

class CreditCard < PaymentMethod
 # ...
end

class PayPal < PaymentMethod
 # ...
end

I see in the request XML that it knows that the payment_method is really
a CreditCard or Invoice (note the xsi:type).

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <env:Body>
    <n1:CreatePayment xmlns:n1="urn:ActionWebService"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
      <payment_method
xmlns:n2="http://www.ruby-lang.org/xmlns/ruby/type/custom";
xsi:type="n2:CreditCard">
        ...
      </payment_method>
    </n1:CreatePayment>
  </env:Body>
</env:Envelope>

However, when I attempt to switch in the controller based on the type of
the payment_method it doesn't seem to remember that it knows this.  Is
it not possible to use this type of polymorphism in service parameters
or am I doing something wrong?

Any help would be much appreciated.

Thanks in advance,
Jason
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to