How to invoke BIP Report Using Python Script
import xml.etree.ElementTree as ET
import requests
import base64
import urllib
urllib.request.getproxies()
# https proxy
proxies={ 'https': 'www-test.xx.yourproxy.com' }
#use proxy if required,else you can ignore and remove the parameter from request too
print("----********-------------")
print("Logic to invoke OBIEE")
url="https://fa-esec-saasfademo1.ds-fa.oraclepdemos.com/xmlpserver/services/PublicReportService?wsdl"
user='fas17.student'
pas='tSR4B%4?'
Headers= {'content-type': 'text/xml','SOAPAction': ''}
print('Username/Password: '+user+'/'+pas)
soapQueryRequest="""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pub="http://xmlns.oracle.com/oxp/service/PublicReportService">
<soapenv:Header/>
<soapenv:Body>
<pub:runReport>
<pub:reportRequest>
<pub:parameterNameValues>
<!--1st Parameter of BIP Report-->
<pub:item>
<pub:name>p_ledger_name</pub:name>
<pub:values>
<pub:item>US IFRS Secondary Ledger</pub:item>
</pub:values>
</pub:item>
</pub:parameterNameValues>
<pub:attributeFormat>csv</pub:attributeFormat>
<pub:flattenXML>false</pub:flattenXML>
<pub:reportAbsolutePath>/Custom/Sreeram/GLLedgerRepo.xdo</pub:reportAbsolutePath>
<pub:sizeOfDataChunkDownload>-1</pub:sizeOfDataChunkDownload>
</pub:reportRequest>
<pub:userID>"""+user+"""</pub:userID>
<pub:password>"""+pas+"""</pub:password>
</pub:runReport>
</soapenv:Body>
</soapenv:Envelope>"""
response = requests.post(url,data=soapQueryRequest,headers=Headers,proxies=proxies)
st=(response.content)
print(st)
outputXML = open("output.xml", "w")
str=st.decode('utf-8')
outputXML.write(str)
outputXML.close()
Output
Base64 Decode Logic In Python
import base64
print("-----XML File Content--------")
readXML=open("output.xml","r")
#logic to parse xml data
for line in readXML.readlines():
print (line)
if 'reportBytes' in line:
x = line.split('reportBytes')[1]
x = x.replace('>','')
x = x.replace('</','')
print('ReportOutput--' + x + '\n')
finalOutput=base64.b64decode(x)
finalOutput=finalOutput.decode('utf-8')
print("final output------------")
print(finalOutput)
outputNewXML = open("outputNew.txt", "w" ,encoding='utf-8')
outputNewXML.write(finalOutput)
#print("----********-------------")
Comments |0|
Category: BIP