本地保存并解析suds响应?

2024-05-18 15:18:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我不熟悉肥皂和肥皂水。我正在使用suds调用非XML SOAP API。一个给定的结果包含大量不同的子数组。我想我可以将整个响应保存在本地,以便以后解析,但说起来容易做起来难。我不喜欢内置缓存选项,你可以缓存x天或其他什么。我可以在本地永久保存和解析响应吗?在


Tags: api选项数组xml内置soapsuds肥皂
1条回答
网友
1楼 · 发布于 2024-05-18 15:18:53

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

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)

相关问题 更多 >

    热门问题