Forum: Ruby on Rails ActionWebService::Struct --> minOccurs?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
brian (Guest)
on 2006-01-22 23:49
Howdy,

In extending ActionWebService::Struct and naming members, is it possible
to indicate them as optional (yielding minOccurs="0" in the wsdl)? For
example, suppose I want to create a request object that can either work
via a number id or a string name (think of it as a union).

class Identifier < ActionWebService::Struct
  member :id, :int
  member :name, :string
end

&gt;xsd:complexType name="Identifier"&lt;
  &gt;xsd:all&lt;
    &gt;xsd:element name="id" type="xsd:int"/&lt;
    &gt;xsd:element name="name" type="xsd:string"/&lt;
  &gt;&gt;/xsd:all&lt;
&gt;/xsd:complexType&lt;

but I want something like:

&gt;xsd:complexType name="Identifier"&lt;
  &gt;xsd:all&lt;
    &gt;xsd:element name="id" type="xsd:int" minOccurs="0"
maxOccurs="1"/&lt;
    &gt;xsd:element name="name" type="xsd:string" minOccurs="0"
maxOccurs="1"/&lt;
  &gt;/xsd:all&lt;
&gt;/xsd:complexType&lt;

And when I receive my Identifier object in code, I can call
identifier.id? identifier.name? to know if a member was specified.

I don't think this is possible, but I thought I'd ask. :^)

Thanks,
Brian
This topic is locked and can not be replied to.