How can I stop Spyne from wrapping arguments in a complexType?

夙愿已清 提交于 2021-01-27 17:26:19

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!