Search code examples
pythonxmlsoapspyne

Wrapping array of elements in spyne


I'm trying to construct a SOAP service with Spyne that has method addUsers, which takes a single argument (users - exactly one instance) provided in such structure:

<users>
  <user>
    <name>Jake</name>
    <age>123</age>
  </user>
  <user>
    ...
  </user>
  ...
</users>

I have the user specified like so:

class user(ComplexModel):
  name = String()
  age = Integer()

But how would I go about adding the users-wrapper? And what would the arguments to @rpc() decorator look like?


Solution

  • Did you try Array(User) ? It didn't work?

    @rpc(Array(User))
    def get_users(ctx, users):
        # (...)