如何在使用名为“pysimplesoap”的Python模块时为WSDL元素设置minOccurs="0"或nillable="true
我们使用pysimplesoap这个模块来编写服务,客户端是用Java写的。不过在把xml数据类型转换成Java时遇到了一些问题。我想我们需要在wsdl元素上设置minOccurs="0"或者nillable="true"。但是在pysimplesoap的一个名为server.py的文件里,这种转换只针对数组进行了处理。请问有没有办法在不搞一些临时解决方案的情况下做到这一点?
1 个回答
0
像往常一样配置调度器:
dispatcher.register_function('test_function', test,
returns={'Success': str},
args={'wanted': str,'optional': str,'another_optional':str })
在定义你的方法时,给可选的字段设置默认值:
def test_request(wanted, optional=None, another_optional="Optional"):
return "Success"