Spyne-如何复制由spyne创建的wsdl文件的一个元素? [英] Spyne - how to duplicate one elements of wsdl file created by spyne?

查看:79
本文介绍了Spyne-如何复制由spyne创建的wsdl文件的一个元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要复制生成的wsdl文件的元素之一.我的代码是这样的:

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

我想用Spyne创建这样的请求wsdl文件:

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>

如何编写我的代码以复制wsdl文件中的regionIds并发送 像上面这样的要求?

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

推荐答案

我终于找到了:) 为此,我必须这样编写我的代码:

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

使用这部分代码: Unicode.customize(max_occurs = 50)我可以指定多少次<regionIds></regionIds> 可以重复.

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

这篇关于Spyne-如何复制由spyne创建的wsdl文件的一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆