Reputation: 3596
Suppose I use python zeep to execute a query against a server like this:
from zeep import Client
wsdl_url = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL"
client = Client(wsdl_url)
result = client.service.ListOfContinentsByCode()
I would like to see the raw XML that comes back from this method, ie extract it somehow from result. Is this possible? How?
Upvotes: 6
Views: 13254
Reputation: 570
If you are trying to debug the XML in a zeep
request or response you can use standard Python logging. From the documentation:
To see the SOAP XML messages which are sent to the remote server and the response received you can set the Python logger level to DEBUG for the
zeep.transports
module.
logging.config.dictConfig({
...
'loggers': {
'zeep.transports': {
'level': 'DEBUG',
'propagate': True,
'handlers': ['console'],
},
},
})
Upvotes: 3
Reputation: 1597
I think what you are looking for is the history plugin.
from zeep.plugins import HistoryPlugin
from zeep import Client
from lxml import etree
wsdl_url = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL"
history = HistoryPlugin()
client = Client(wsdl_url, plugins=[history])
client.service.CurrencyName('GBP')
your_pretty_xml = etree.tostring(history.last_received["envelope"], encoding="unicode", pretty_print=True)
Upvotes: 8
Reputation: 23825
Here (requests takes care of the gzip)
import requests
r = equests.get('http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL')
if r.status_code == 200:
print(r.content)
Upvotes: -3