Spyne - how to duplicate one elements of wsdl file created by spyne?

懵懂的女人 提交于 2019-12-08 03:13:26

问题


I need to duplicate one of the elements of generated wsdl file. My code is like this:

class SDPSimulator(ServiceBase):
@rpc(UserCredential, Unicode, Unicode, Unicode, Integer,
     _returns=SendSmsReturn.customize(sub_name='return'))
def sendSms(ctx, userCredential, srcAddress, regionIds,msgBody,maxSendCount): 

I want to create my request wsdl file like this with Spyne:

<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>

How can I write my code to duplicate regionIds in wsdl file and send a request like above?


回答1:


I finally find it :) To do so I have to write my code like this:

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):

With this part of code: Unicode.customize(max_occurs=50) I can specify how many times <regionIds></regionIds> could be duplicated.



来源:https://stackoverflow.com/questions/42453596/spyne-how-to-duplicate-one-elements-of-wsdl-file-created-by-spyne

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