0

我有这项服务:

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):
        ...

这在 WSDL 中显示为:

<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>

我希望category_path参数是 1 个或多个整数的数组,但Array(Integer(min_occurs=1, max_occurs='unbounded', nillable=False)对我不起作用。

4

1 回答 1

1

Array用于包装数组类型。要获得简单的,您应该直接使用类型标记。以下应该可以解决问题:

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):
        # (...)
于 2013-08-30T06:05:01.407 回答