简体   繁体   中英

Python Zeep is throwing unkown fault for soap request

I am new to using the framework zeep. I am trying to send a SOAP request . But I get the below incorrect data. I need to get the response in xml or csv format.

<Element {http://schemas.xmlsoap.org/soap/envelope/}Envelope at 0x7fabdc9ea888>

With the wsdl, I am able to fetch the correct output using SoapUI tool.

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)

Since you are creating the message, print(results) is just showing the message object created.

Instead this should work to print the message on screen:

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))

If you want to see the response of the RetrieveID operation. then do this instead (Provided this method is bound on 1st available binding):

response = client.service.RetrieveID(**request_data)
print(response)

Let us know if it doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM