调用在Suds,Python上使用特定类型的函数

时间:2016-11-23 21:01:55

标签: python soap types suds

我有以下代码:

import logging
logging.basicConfig(level=logging.INFO)

logging.getLogger('suds.client').setLevel(logging.DEBUG)

from suds.client import Client
url = 'https://webpay3gint.transbank.cl/WSWebpayTransaction/cxf/WSWebpayService?wsdl'

client = Client(url)

print client

产生以下输出:

Service ( WSWebpayServiceImplService ) tns="http://service.wswebpay.webpay.transbank.com/"
   Prefixes (1)
      ns0 = "http://service.wswebpay.webpay.transbank.com/"
   Ports (1):
      (WSWebpayServiceImplPort)
         Methods (3):
            acknowledgeTransaction(xs:string tokenInput, )
            getTransactionResult(xs:string tokenInput, )
            initTransaction(wsInitTransactionInput wsInitTransactionInput, )
         Types (14):
            acknowledgeTransaction
            acknowledgeTransactionResponse
            cardDetail
            getTransactionResult
            getTransactionResultResponse
            initTransaction
            initTransactionResponse
            transactionResultOutput
            wpmDetailInput
            wsInitTransactionInput
            wsInitTransactionOutput
            wsTransactionDetail
            wsTransactionDetailOutput
            wsTransactionType

如您所见,某些方法(initTransaction)使用自定义类型(wsInitTransactionInput),如何创建该自定义类型的元素,以便我能够调用initTransaction()?

1 个答案:

答案 0 :(得分:2)

解决方案是写:

object = client.factory.create('wsInitTransactionInput')
client.service.initTransaction(object)

这是在suds文档中。