0
votes

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)
1
Show us the error you receive - Tarique
I do not get any error . I just get the below . <Element {schemas.xmlsoap.org/soap/envelope}Envelope at 0x7fabdc9ea888> - stacktesting
its printing the results object. Try print(results.content) - Tarique
I tried. It gives below error. AttributeError: 'lxml.etree._Element' object has no attribute 'contents' - stacktesting
It is a zeep method . PFB. When you want zeep to build and return the XML instead of sending it to the server you can use the Client.create_message() call. - stacktesting

1 Answers

0
votes

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.