'''
https://docs.oracle.com/middleware/1221/biee/BIEIT/methods.htm
'''
from suds.client import Client
# Logon
client = Client('http://MYHOST:9502/analytics-ws/saw.dll/wsdl/v7')
sessionid = client.service['SAWSessionService'].logon('weblogic','welcome1')
# Params
reportPath = {
'reportPath': '/users/weblogic/Prueba_Web_Services' # Ruta al informe
}
XMLQueryExecutionOptions = {
'async':False,
'maxRowsPerPage':150,
'refresh':True,
'presentationInfo':True,
'type':'test'
}
reportParams = {
'filterExpressions': ['''<sawx:expr xsi:type="sawx:comparison" op="equal" subjectArea="Sales" xmlns:saw="com.siebel.analytics.web/report/v1.1" xmlns:sawx="com.siebel.analytics.web/expression/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<sawx:expr xsi:type="sawx:sqlExpression">"Incident Attributes"."Incident Location"</sawx:expr>
<sawx:expr xsi:type="xsd:string">100 Federal</sawx:expr>
</sawx:expr>'''],
'variables': [{'name': 'brand', 'value': 'FunPod'}], # Variables del informe
'nameValues': None,
'templateInfos': None,
'viewName': None # Nombre de la vista del informe e.j.: "tableView!1" (None=Todas las columnas)
}
# Execute
service = client.service['XmlViewService']
result = service.executeXMLQuery(reportPath, 'SAWRowsetSchemaAndData', XMLQueryExecutionOptions, reportParams, sessionid)
# Fetch
dataset = [result.rowset]
while not result.finished:
result = service.fetchNext()
dataset.append(result.rowset)
# Save
with open('export_'+ result.queryID +'.xml', 'w', encoding='utf-8') as f:
f.writelines(dataset)