Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Zeep正在为soap请求抛出未知错误_Python_Python 3.x_Soap_Soapui_Zeep - Fatal编程技术网

Python Zeep正在为soap请求抛出未知错误

Python Zeep正在为soap请求抛出未知错误,python,python-3.x,soap,soapui,zeep,Python,Python 3.x,Soap,Soapui,Zeep,我对使用zeep框架还不熟悉。我正在尝试发送SOAP请求。但是我得到了下面不正确的数据。我需要得到xml或csv格式的响应 使用wsdl,我能够使用SoapUI工具获取正确的输出 from requests import Session from zeep import Client from zeep.transports import Transport from requests.auth import AuthBase, HTTPBasicAuth import datetime w

我对使用zeep框架还不熟悉。我正在尝试发送SOAP请求。但是我得到了下面不正确的数据。我需要得到xml或csv格式的响应

使用wsdl,我能够使用SoapUI工具获取正确的输出

from requests import Session
from zeep import Client
from zeep.transports import Transport
from requests.auth import AuthBase, HTTPBasicAuth
import datetime

wsdl = 'http://XX.XXX.XX.XX:ZZZZ/TL/IM?wsdl'

session = Session()
session.auth = SymantecAuth('user','password', "http://XX.XXX.XX.XXX")
session.verify = False
transport = Transport(session=session)

client = Client(wsdl=wsdl, transport=transport)

request_data = {"platforms": "test", "platid": {"ID": "QI4552"}}

results=client.create_message(client.service, 'RetrieveID', request_data)
print(results)

由于您正在创建消息,
print(results)
只是显示创建的消息对象

相反,这可以在屏幕上打印消息:

from lxml import etree

# Your code follows here

results=client.create_message(client.service, 'RetrieveID', request_data)
# this will print the message to be sent to Soap service.
print(etree.tostring(results, pretty_print=True))
如果要查看
RetrieveID
操作的响应。然后改为执行此操作(前提是此方法在第一个可用绑定上绑定):


如果不起作用,请告诉我们。

显示您收到的错误。我没有收到任何错误。我只是得到下面的答案。它将打印
结果
对象。试着打印(results.content)我试过了。它给出了以下错误。AttributeError:'lxml.etree.\u元素'对象没有属性'contents',它是一个zeep方法。PFB。当您希望zeep生成并返回XML而不是将其发送到服务器时,您可以使用Client.create_message()调用。上面没有给出输出。它只是将输入打印为xml这是您要求以xml或csv格式打印结果的要求。否?是否要获取
RetrieveID
方法调用的响应?是。我需要xml或csv格式的响应检查我的答案,我更新了它
response = client.service.RetrieveID(**request_data)
print(response)