0

I have this service:

class CategoryService(ServiceBase):

    @rpc(Array(Integer(min_occurs=1, max_occurs='unbounded', nillable=False), **MANDATORY),
         _returns=Iterable(Category, **MANDATORY))
    def get_subcategories_by_path(ctx, category_path):
        ...

This is shown in WSDL as:

<xs:complexType name="get_subcategories_by_path">
  <xs:sequence>
    <xs:element name="category_path" type="tns:integerArray"/>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="integerArray">
  <xs:sequence>
    <xs:element name="integer" type="xs:integer" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
  </xs:sequence>
</xs:complexType>

I want category_path argument to be an array of 1 or more integers, but Array(Integer(min_occurs=1, max_occurs='unbounded', nillable=False) does not work for me.

warvariuc
  • 57,116
  • 41
  • 173
  • 227

1 Answers1

1

Array is for wrapped array types. To get simple ones, you should use the type markers directly. The following should do the trick:

class CategoryService(ServiceBase):
    @rpc(Integer(min_occurs=1, max_occurs='unbounded', nillable=False)),
                                        _returns=Iterable(Category, **MANDATORY))
    def get_subcategories_by_path(ctx, category_path):
        # (...)
Burak Arslan
  • 7,671
  • 2
  • 15
  • 24
  • Does this mean that `@rpc(Mandatory.Unicode, Array(Unicode, default='*'), Array(Unicode), Array(Unicode), Array(Unicode), _returns=ProductWithRelations) def get_product_by_sku( ctx, product_sku, include_columns, exclude_columns, include_relationships, exclude_relationships):` can be safely rewritten as `@rpc(Mandatory.Unicode, Unicode(max_occurs='unbounded', default='*'), Unicode(max_occurs='unbounded'), Unicode(max_occurs='unbounded'), Unicode(max_occurs='unbounded'), _returns=ProductWithRelations)`? – warvariuc Aug 30 '13 at 06:58
  • uh, no, you have 4 arrays in the first and one array in the second. Also, the wsdl produced by Array(...) and Unicode(max_occurs='unbounded') is different. – Burak Arslan Sep 02 '13 at 06:23
  • but looks like the second form is fine: ` ` – warvariuc Sep 02 '13 at 08:09
  • Well, if it looks fine, nothing will change in the python side. Both will deserialize as arrays of designated types. – Burak Arslan Sep 02 '13 at 11:44