本地保存和解析suds响应?

时间:2015-03-28 00:07:36

标签: python soap suds

我是SOAP和suds的新手。我使用suds调用非XML SOAP API。给定结果包含大量不同的子阵列。我以为我会在本地保存整个响应以便稍后解析但说起来容易做起来难。而且我没有使用内置缓存选项获得此业务,您可以缓存x天或其他任何内容。我可以在本地永久保存和解析响应吗?

1 个答案:

答案 0 :(得分:0)

您可以将响应写入本地文件:

client = Client("http://someWsdl?wsdl")

# Getting response object
method_response = client.service.someMethod(methodParams)

# Open local file
fd = os.open("response_file.txt",os.O_RDWR|os.O_CREAT)

# Convert response object into string
response_str = str(method_response)

# Write response to the file
ret = os.write(fd,response_str)

# Close the file
os.close(fd)
相关问题