1

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?

Majid
  • 1,673
  • 18
  • 27
Fatemeh Rostami
  • 1,047
  • 1
  • 15
  • 27

1 Answers1

3

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.

Community
  • 1
  • 1
Fatemeh Rostami
  • 1,047
  • 1
  • 15
  • 27
  • 1
    Use `max_occurs='unbounded'` or `max_occurs=Decimal('inf')` rather than 50 (which I imagine is just an arbitrary "high" value) – Burak Arslan Feb 27 '17 at 09:47