[Soap-Python] Spyne: ability to change default results name from FooResult to WhateverXyz ?
Burak Arslan
burak.arslan at arskom.com.tr
Tue Apr 21 17:31:31 CEST 2015
On 04/21/15 06:52, Patricio Stegmann Gmail wrote:
> The bare parameter is forcing me to have, for the decorated function,
> only one parameter of input,
SOAP defines a way to map an XML document to a method call. Actually,
that's like this for every serialization standard / RPC standard pair.
For example JsonRPC is a standard to map an incoming json document to a
method call. XmlRpc is another way of mapping xml documents to method
calls, etc..
So in normal (non-bare) mode, you define your method and Spyne generates
needed input and output objects for you. In bare mode, it's your job to
define these objects. That's why you can only have a single input and
single output object.
So if your method needs to take two arguments, you have to do what Spyne
does behind the scenes and define a complex model that has two
attributes and use that object as type of the single argument to your
method.
The "one object == one method call" is the fundamental design principle
behind Spyne[1].
If that's clear, let's get back to your case. You need:
class InitializeRequest(ComplexModel):
__type_name__ = 'Initialize'
__namespace__ = 'tns' # whatever you passed to your app as tns
argument
_type_info = [
('id', Unicode),
('name', Unicode),
]
and
class SomeService(ServiceBase):
@rpc(InitializeRequest, _body_style='bare')
def wicked(ctx, request):
print "id:", request.id
print "name:", request.name
If you need to have the namespace of your incoming object different from
your app's tns, you need latest code from github.com/arskom/spyne. I
just found out 2.11 doesn't support that.
I hope this helps.
Best,
Burak
[1]: That doesn't mean one document can't contain more than one object,
but that's not implemented because I don't see the point.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/soap/attachments/20150421/a693be97/attachment.html>
More information about the Soap
mailing list