我需要复制生成的wsdl文件的一个元素。我的代码是这样的:
class SDPSimulator(ServiceBase):
@rpc(UserCredential, Unicode, Unicode, Unicode, Integer,
_returns=SendSmsReturn.customize(sub_name='return'))
def sendSms(ctx, userCredential, srcAddress, regionIds,msgBody,maxSendCount):
我想用Spyne创建我的请求wsdl文件:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:loc="localhost" xmlns:apps="apps.simulator.views">
<soapenv:Header/>
<soapenv:Body>
<loc:sendSms>
<!--Optional:-->
<loc:userCredential>
<!--Optional:-->
<apps:password>test</apps:password>
<!--Optional:-->
<apps:username>test</apps:username>
</loc:userCredential>
<!--Optional:-->
<loc:srcAddress>982156898</loc:srcAddress>
<!--Optional:-->
<loc:regionIds>77</loc:regionIds>
<loc:regionIds>78</loc:regionIds>
<loc:regionIds>79</loc:regionIds>
<!--Optional:-->
<loc:msgBody>Hi there</loc:msgBody>
<!--Optional:-->
<loc:maxSendCount>12</loc:maxSendCount>
</loc:sendSms>
</soapenv:Body>
</soapenv:Envelope>
如何编写代码以复制wsdl文件中的regionIds并发送 请求如上所述?
答案 0 :(得分:3)
我终于找到了:) 为此,我必须编写如下代码:
class SDPSimulator(ServiceBase):
@rpc(UserCredential, Unicode, Unicode.customize(max_occurs='unbounded'), Unicode, Integer,
_returns=SendSmsReturn.customize(sub_name='return'))
def sendSms(ctx, userCredential, srcAddress, regionIds, msgBody, maxSendCount):
使用这部分代码: Unicode.customize(max_occurs = 50)我可以指定<regionIds></regionIds>
的次数
可以复制。