问题
I'm trying to use Spyne to provide web services from Python. I have everything working for a test function called SayHello(name, times). However, I'm wondering why Spyne wraps the name and times arguments in a complexType called SayHello? This makes consuming the web service in .NET much more cludgey (i.e. instead of appClient.SayHello("Dave", 5)
I have to do SayHello args = new SayHello(); args.name = "Dave"; args.times = "5"; appClient.SayHello(args);
which is very inelegant).
Is there a way to force Spyne not to wrap arguments in a complexType?
Here's the relevant portion of the current wsdl that Spyne generates:
<xs:schema targetNamespace="solutions.sfcs" elementFormDefault="qualified">
<xs:complexType name="SayHello">
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0" nillable="true"/>
<xs:element name="times" type="xs:integer" minOccurs="0" nillable="true"/>
</xs:sequence>
</xs:complexType>
回答1:
You can pass _body_style='bare'
to the @rpc
decorator to prevent that wrapping. But you'll most likely get:
Exception: body_style='bare' can handle at most one function argument.
If you can fix this in a way that doesn't break other tests, I can merge your patch.
来源:https://stackoverflow.com/questions/15395610/how-can-i-stop-spyne-from-wrapping-arguments-in-a-complextype