I have zeep pulling soap data from a SOAP endpoint as:
'''<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetLogCategoriesResponse xmlns="http://mynamespace.net/client">
<GetLogCategoriesResult>
<IsSuccessful>true</IsSuccessful>
<Messages />
<Categories>
<LogCategory>
<Category>Client Call</Category>
<CategoryId>805</CategoryId>
<CategoryType>UDF</CategoryType>
</LogCategory>
<LogCategory>
<Category>Client Portal</Category>
<CategoryId>808</CategoryId>
<CategoryType>UDF</CategoryType>
</LogCategory>
<LogCategory>
<Category>Complaint Notes</Category>
<CategoryId>1255</CategoryId>
<CategoryType>UDF</CategoryType>
</LogCategory>
</Categories>
</GetLogCategoriesResult>
</GetLogCategoriesResponse>
</soap:Body>
</soap:Envelope>'''
I've tried pulling the data using Elementtree as below without success:
'''from zeep import Client, Transport
import xml.etree.ElementTree as ET
client = Client('http://sandbox.mynamespace.net/Client.asmx?wsdl')
with client.settings(raw_response=True):
soap_result = client.service.GetLogCategories(userName='user', password='pass')
namespaces = {
'soap': 'http://schemas.xmlsoap.org/soap/envelope/',
'a': 'http://mynamespace.net/client',
}
dom = ET.fromstring(soap_result.content)
print(dom)
names = dom.findall(
'./soap:Body'
'./a:GetLogCategoriesResponse'
'./a:GetLogCategoriesResult'
'./a:Categories'
'./a:LogCategory'
'./a:Category',
namespaces,)
print(names)
for name in names:
print('in For')
print(name.text)'''
I do have a partially working but it only pulls back the first instance of the data group, I need to pull back all groups:
'''from zeep import Client, Transport
from bs4 import BeautifulSoup
client = Client('http://sandbox.mynamespace.net/2.18/Client.asmx?wsdl')
with client.settings(raw_response=True):
soap_result = client.service.GetLogCategories(userName='uname', password='pass')
soup = BeautifulSoup(soap_result.text, 'html.parser')
searchTerms = ['Category','CategoryId','CategoryType']
for st in searchTerms:
print(st+'\t',)
print(soup.find(st.lower()).contents[0])'''
I am looking for any pointers or solutions that will work at this point. Thanks again