python spyne:摆脱方法定义中的ComplexTypes

时间:2013-04-19 10:13:02

标签: python soap spyne

我用spyne构建了一个简单的服务,有一个问题 - 它会将方法输入参数包装成复杂的类型 - :

class JiraAdapter(ServiceBase):

    @srpc(Unicode, Unicode, Unicode, _returns=String)
    def CreateJiraIssueWithBase64Attachment(summary, base64attachment, attachment_filename):
        status = Status
        try:
            newkey = jira_client.createWithBase64Attachment(summary, base64attachment.decode('string-escape'), attachment_filename)
            status.Code = StatusCodes.IssueCreated
            status.Message = unicode(newkey)
        except Exception as e:
            status.Code = StatusCodes.FailedToCreateIssue
            status.Message = u'Internal Exception: %s' % e.message
        return status.__str__()

    application = Application([JiraAdapter],
    tns='JiraAdapter',
    in_protocol=Soap11(),
    out_protocol=Soap11()
)

结果在以下WSDL中(仅处理相对位):

<wsdl:portType name="Application">
<wsdl:operation name="CreateJiraIssueWithBase64Attachment" parameterOrder="CreateJiraIssueWithBase64Attachment">
<wsdl:input name="CreateJiraIssueWithBase64Attachment" message="tns:CreateJiraIssueWithBase64Attachment"/>
<wsdl:output name="CreateJiraIssueWithBase64AttachmentResponse" message="tns:CreateJiraIssueWithBase64AttachmentResponse"/>
</wsdl:operation>
</wsdl:portType>

    ....

<xs:complexType name="CreateJiraIssueWithBase64Attachment">
<xs:sequence>
<xs:element name="summary" type="xs:string" minOccurs="0" nillable="true"/>
<xs:element name="base64attachment" type="xs:string" minOccurs="0" nillable="true"/>
<xs:element name="attachment_filename" type="xs:string" minOccurs="0" nillable="true"/>
</xs:sequence>
</xs:complexType>

有没有办法让spyne构建wsdl的方式只需要一系列参数?客户端应用程序是用VBA编写的,上帝只知道如何用它提交复杂的类型参数。

0 个答案:

没有答案