Python 使用AWS lambda、Zeep和IRESS创建REST API

Python 使用AWS lambda、Zeep和IRESS创建REST API,python,amazon-web-services,amazon-s3,aws-lambda,zeep,Python,Amazon Web Services,Amazon S3,Aws Lambda,Zeep,在下面的代码中,我使用SOAP API创建IRESS会话。我能够在jupyter上运行会话,但在AWS Lambda中运行会话时遇到问题。由于API网关中的时间限制为29秒,我在使用API网关触发时收到API网关超时错误 from zeep import Client, Settings from decimal import Decimal import sys import logging import os import time import sys import click impor

在下面的代码中,我使用SOAP API创建IRESS会话。我能够在jupyter上运行会话,但在AWS Lambda中运行会话时遇到问题。由于API网关中的时间限制为29秒,我在使用API网关触发时收到API网关超时错误

from zeep import Client, Settings
from decimal import Decimal
import sys
import logging
import os
import time
import sys
import click
import distutils.util
import uuid
from zeep import Client
from zeep.cache import SqliteCache
from zeep.transports import Transport
from lxml import etree
import operator
import json
from random import seed
from random import random
iressMethodList = "AlertCreate,AlertGet,AlertDelete"
username2 ="testuser2"
username  = "testuser"
password ="testpassword"
endpoint =  "https://webservicestesta.iress.com.au/v4/"
companyname = "company"
iosname = 'iosname'
service_ios='IOSPLUS'
service_iresss='IRESS'
service_ips='IPS';srv = 'IPSCACHE'
app_id = str(random())
settings = Settings(strict = False, xml_huge_tree = True)
WSDL_IOS_GENERIC='http://webservices.iress.com.au/v4/wsdl.aspx?un={username}&cp={companyname}&svc=IOSPLUS&svr=cache9&pw={password}'
WSDL_IRESS_GENERIC='https://webservices.iress.com.au/v4/wsdl.aspx?un={username}&cp={companyname}&pw={password}&svc=IRESS&svr=cache9'
WSDL_IOS_URL = WSDL_IOS_GENERIC.format(companyname=companyname,username=username,password=password)
WSDL_IRESS_URL = WSDL_IRESS_GENERIC.format(companyname=companyname,username=username,password=password)
# Create the Web Services client objects, one for the IOS+ WSDL and one for the IRESS WSDL
iosPlusClient = Client(WSDL_IOS_URL, settings=settings)#,transport=transport2)
iressClient = Client(WSDL_IRESS_URL, settings=settings)#, transport=transport1)
iosPlusClientFactory = iosPlusClient.type_factory('ns0')
iressClientFactory = iressClient.type_factory('ns0')
#create the connection and key
iressSessionStartResponse = iosPlusClient.service.IRESSSessionStart(iosPlusClientFactory.IRESSSessionStartInput(Header=iosPlusClientFactory.IRESSSessionStartInputHeader(Updates=False), Parameters=iosPlusClientFactory.IRESSSessionStartInputParameters(SessionNumberToKick=-1,ApplicationID=app_id, UserName=username, CompanyName=companyname, Password=password)))
iressSessionKey = iressSessionStartResponse.Result.DataRows.DataRow[0].IRESSSessionKey
serviceSessionStartResponse = iosPlusClient.service.ServiceSessionStart(iosPlusClientFactory.ServiceSessionStartInput(Parameters=iosPlusClientFactory.ServiceSessionStartInputParameters(IRESSSessionKey=iressSessionKey, Service= "IOSPLUS", Server=iosname)))
serviceSessionKey = serviceSessionStartResponse.Result.DataRows.DataRow[0].ServiceSessionKey
在第一部分中,我想调用触发AWS Lambda函数的API网关来创建IRESS会话,并将serviceSessionKey和iressSessionKey与对象(iosPlusClient、IResClient、iosPlusClient Factory、IResClient Factory)一起存储在S3存储桶中正如在上面的函数中使用的那样,这样我也可以在其他函数中使用它们。 在下一部分中,我想创建一个帐户,该帐户具有以下代码:

account = iosPlusClientFactory.AccountGetInput(
    Header={
        'ServiceSessionKey': serviceSessionKey,
    },
    Parameters={
    }
)
account_detail = iosPlusClient.service.AccountGet(account)
在这里,我需要serviceSessionKey和iosPlusClientFactory,它们将存储在第一个函数中