6 Replies Latest reply on Dec 17, 2011 6:32 PM by 629225

    OBIEE's Web Service SOAP-API + HtmlViewService + Access is Denied error

      I am using C# to connect to OBIEE's SOAP-API and pull HTML for an Answer's report. I would like to take this HTML, and at the most basic level, display the report in a file called report.html.

      I have successfully been able to connect to the API, create an HtmlViewService object, and use a combination of the following methods to pull back HTML for a report and write to a file: addReportToPage, getHeadersHTML, getCommonBodyHTML, and getHTMLForReport.

      My issue is that after I write the HTML to a file and load up the report in the browser, I get an "Access is Denied" error from the iframe present in the HTML. I figured this is because of cross-domain scripting since I have references to JavaScript files on the OBIEE Server. I have also tried the exact same process with the OBIEE server on localhost and receive the same "Access is Denied" error due to the iframe. Additionally I have tried bringing all the JavaScript locally and continue to have the same issue (seems as though the iframe is the sole cause).

      I have two major questions:
      - How can I eliminate the Access is Denied error and display the report on the page? (All I am getting is the "Searching..." icon and the report never loads)
      - Is there a way to return the actual raw HTML from the report rather than using an iframe with a src attribute pointed to the SOAP-API? Is this a design decision so that reports are dynamically populated rather than having to re-pull the HTML every time it is viewed?

      In terms of the JavaScript error, it looks like I need to setup a bridge (which I tried and may or may not have been successful), but due to the fact that I tried this whole process locally I am hesitant to dig into that before getting some help from an Oracle expert. Additionally, I tried setting the locales in a SAWLocale object and a SAWSessionParameters object, but am not totally sure that this should effect the errors I am getting.

      I would appreciate assistance with this. Thanks in advance.


      The example below is actual implemented in a custom SharePoint webpart, but I have done the same thing in a normal C# class, while writing to a file locally and I get the same error results.

      using System;
      using System.ComponentModel;
      using System.IO;
      using System.Text;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using Microsoft.SharePoint;
      using Microsoft.SharePoint.WebControls;
      using Microsoft.SharePoint.WebPartPages;
      using System.Web.Configuration;
      using System.Collections.Generic;
      using PortalOBIEE.local_obiee;

      namespace PortalOBIEE.OBIEEReport
      public class OBIEEReport : System.Web.UI.WebControls.WebParts.WebPart
      // Visual Studio might automatically update this path when you change the Visual Web Part project item.
      private const String ascxPath = @"~/CONTROLTEMPLATES/PortalOBIEE/OBIEEReport/OBIEEReportUserControl.ascx";
      static private System.Net.CookieContainer cookies = new System.Net.CookieContainer();
      static private SAWSessionService m_session = new SAWSessionService();
      static private WebCatalogService m_WebCatalogService = new WebCatalogService();
      static private HtmlViewService HTMLservice = new HtmlViewService();
      static private XmlViewService XMLview = new XmlViewService();
      static Random rand = new Random();
      static String m_SessionID = null;
      static String strURL = "";
      static String strUser = "Administrator";
      static String strPWD = "Administrator";
      static String reportID = "reportWithLocaleAndParams";
      static String report_path = "/shared/service/report";

      protected override void OnLoad(EventArgs e)
      SAWLocale sawlocale = new SAWLocale();
      sawlocale.language = this.Page.Request.UserLanguages[0];
      SAWSessionParameters sessionparams = new SAWSessionParameters();
      sessionparams.userAgent = this.Page.Request.UserAgent;
      sessionparams.locale = sawlocale;
      sessionparams.asyncLogon = false;

      protected void createSession()
      /* create session with OBIEE Server */
      m_WebCatalogService.CookieContainer = cookies;
      m_session.CookieContainer = cookies;
      m_session.Url = strURL + "?SoapImpl=nQSessionService";
      //String sessionID = m_session.logon(strUser, strPWD);
      SAWSessionParameters pars = new SAWSessionParameters();
      pars.userAgent = this.Page.Request.UserAgent;
      pars.asyncLogon = false;
      m_SessionID = m_session.logonex(strUser, strPWD, pars).sessionID;
      //HTMLservice.setBridge(@"~/_CONTROLTEMPLATES/PortalOBIEE/OBIEEReport/OracleBridge.ashx", m_SessionID);


      protected void callWebServiceForReportHTML(String sessionID)
      /* call web service and return HTML */
      SPContext.Current.Web.AllowUnsafeUpdates = true;
      HTMLservice.Url = strURL + "?SoapImpl=htmlViewService";
      StartPageParams pageParams = new StartPageParams();
      pageParams.idsPrefix = "ID" + "_" + System.DateTime.Now.Millisecond + "_" + rand.Next();
      pageParams.dontUseHttpCookies = true;
      ReportRef reportRef = new ReportRef();
      reportRef.reportPath = report_path;

           /* get all the HTML at one time */
      String html = HTMLservice.getHtmlForPageWithOneReport(reportID, reportRef, null, null, null, pageParams, sessionID);

           /* manually concatenate all the HTML together */
      //HTMLservice.setBridge("", sessionID);
      //String pageID = HTMLservice.startPage(pageParams, sessionID);
      //HTMLservice.addReportToPage(pageID, reportID, reportRef, null, null, null, sessionID);
      //String header = HTMLservice.getHeadersHtml(pageID, sessionID);
      //String report = HTMLservice.getHtmlForReport(pageID, reportID, sessionID);
      //String body = HTMLservice.getCommonBodyHtml(pageID, sessionID);
      //String html = "<html><head>" + header + "</head><body>" + body + "</body></html>";

      //Control content = Page.ParseControl(body);

      writeHtmlToFile(html, reportID);

      protected void writeHtmlToFile(String html, String ReportName)
      SPWeb spCurrentWeb = SPContext.Current.Web;
      SPDocumentLibrary spdl = (SPDocumentLibrary)spCurrentWeb.Lists["OBIEEReports"];
      SPFile spf = null;

      // Traverse through document library and delete report if exists
      foreach (SPListItem spli in spdl.Items)
      if (spli.File != null && spli.File.Name == ReportName + ".html")

      // delete if exists
      if (spf != null)

      // Create and update the file
      SPFolder spfolder = spCurrentWeb.Folders["http://raustpsw0723/dev/OBIEEReports/"];
      byte[] content = ConvertStringToByteArray(html);
      spf = spfolder.Files.Add(ReportName + ".html", content, true);

      SPContext.Current.Web.AllowUnsafeUpdates = false;


      protected void createReportViewer()
      PageViewerWebPart pv = new PageViewerWebPart();
      pv.Title = "OBIEE Report";
      pv.ID = "OBIEEReport";
      pv.ContentLink = "http://raustpsw0723/dev/OBIEEReports/Sales.html";
      pv.SourceType = PathPattern.URL;
      pv.Height = "500px";
      pv.Width = "500px";
      pv.Visible = true;

      public static byte[] ConvertStringToByteArray(string stringToConvert)
      return new ASCIIEncoding().GetBytes(stringToConvert);

      protected override void CreateChildControls()
      Control control = Page.LoadControl(_ascxPath);

      protected override void Render(HtmlTextWriter writer)

      Edited by: Josh6847 on Apr 5, 2010 11:09 AM
        • 1. Re: OBIEE's Web Service SOAP-API + HtmlViewService + Access is Denied error

          Did you ever find a solution to this problem?
          Did you create an HTTPHandler?

          • 2. Re: OBIEE's Web Service SOAP-API + HtmlViewService + Access is Denied error
            Yes, I was able to create an HTTPhandler. Thanks for following up.

            Here's what mine looks like:

            <%@ WebHandler Language="C#" Class="OracleBridge" %>

            using System;
            using System.Collections;
            using System.Configuration;
            using System.Collections.Specialized;
            using System.Web;
            using System.Text;
            using System.Net;
            using System.IO;
            using System.Diagnostics;

            This is a ASP.NET handler that handles communication
            between the SharePoint site and OracleBI.
            It will be deployed to:
            C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\OracleBI

            public class OracleBridge: IHttpHandler
            public bool IsReusable {get{return true;}}
            public OracleBridge()
            string getServer()
            string strServer = ConfigurationManager.AppSettings["SAWServer"].ToString();
            int index = strServer.LastIndexOf("/");//split off saw.dll
            if (index >=0)
            return strServer.Substring(0,index+1);
            return strServer;
            public void ProcessRequest(HttpContext context)
            HttpWebRequest req = forwardRequest(context);
            private HttpWebRequest forwardRequest(HttpContext context)
            string strURL = makeURL(context);
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURL);
            req.Method = context.Request.HttpMethod;
            NameValueCollection headers = context.Request.Headers;
            req.Accept = headers.Get("Accept");
            req.Expect = headers.Get("Expect");
            req.ContentType = headers.Get("Content-Type");
            string strModifiedSince = headers.Get("If-Modified-Since");
            if (strModifiedSince != null && strModifiedSince.Length != 0)
            req.IfModifiedSince = DateTime.Parse(strModifiedSince);
            req.Referer = headers.Get("Referer");
            req.UserAgent = headers.Get("User-Agent");
            if (!req.Method.Equals("GET"))
            return req;

            private void forwardResponse(HttpContext context, HttpWebRequest req)
            HttpWebResponse resp =null;
            resp = (HttpWebResponse)req.GetResponse();
            catch(WebException e)
            resp = (HttpWebResponse)e.Response;
            context.Response.StatusCode = (int)resp.StatusCode;

            for (int i = 0; i < resp.Cookies.Count; i++)
            Cookie c = resp.Cookies;
            HttpCookie hc = new HttpCookie(c.Name, c.Value);
            hc.Path = c.Path;
            hc.Domain = getServer();
            context.Response.ContentType = resp.ContentType;
            CopyStreams(resp.GetResponseStream(), context.Response.OutputStream);

            private string makeURL(HttpContext context)
            string strQuery = context.Request.Url.Query;
            string[] arrParams = strQuery.Split('?','&');
            StringBuilder resultingParams = new StringBuilder();
            string strURL=null;
            foreach(string strParam in arrParams )
            string[] arrNameValue = strParam.Split('=');
            if (!arrNameValue[0].Equals("RedirectURL"))
            if (strParam.Length != 0)
            if (resultingParams.Length != 0)
            else if (arrNameValue.Length >1)
            strURL = HttpUtility.UrlDecode(arrNameValue[1]);

            if (strURL ==null)
            throw new Exception("Invalid URL format. requestURL parameter is missing");
            String sAppendChar = strURL.Contains("?") ? "&" : "?";
            if (strURL.StartsWith("http:") || strURL.StartsWith("https:"))
            String tmpURL = strURL + sAppendChar + resultingParams.ToString();
            return tmpURL;
            String tmpURL = getServer() + strURL + sAppendChar + resultingParams.ToString();
            return tmpURL;

            private void CopyStreams(Stream inStr,Stream outStr)
            byte[] buf = new byte[4096];
            int iRead = inStr.Read(buf,0,4096);
            if (iRead == 0)
            while (true);
            • 3. Re: OBIEE's Web Service SOAP-API + HtmlViewService + Access is Denied error
              I have tried creating an c# handler based on this example, but I still cannot get the report to display on a aspx page. It looks like the requests are coming through,but I only get the iframe with src attribute and not the actual html of the report. The bridge is set to the ashx handler that is running on my localhost.

              I would appreciate it if anyone would be available to assist. I am a .net developer and struggling to get a simple report to display on an aspx page.

              • 4. Re: OBIEE's Web Service SOAP-API + HtmlViewService + Access is Denied error

                I am new to oracle BI and I know Java. I have a requirement that i have to display OBIEE reports on html pages.
                I followed the steps given in http://oraclebizint.wordpress.com/2007/07/31/customizing-obi-ee-soap-api/ and got the report but not able to display it on the html page.
                It’s showing the moving clock but not showing the report when i see the page source its showing like following

                report_name_ReportObj = new saw.ondemandload.EmbededReport(‘reportname’);
                var reportObject = report_name_ReportObj;

                and my code in the SAWSessionServiceSoapClient is

                public class SAWSessionServiceSoapClient extends Applet
                *private oracle.bi.web.soap.SAWSessionServiceSoap _port;*
                private static SAWSessionService sAWSessionService;
                public SAWSessionServiceSoapClient() throws Exception
                ServiceFactory factory = ServiceFactory.newInstance();
                sAWSessionService = new SAWSessionService();
                _port = sAWSessionService.getSAWSessionServiceSoap();*
                *public static void main(String[] args) {*
                */*sAWSessionService = new SAWSessionService();*
                SAWSessionServiceSoap sAWSessionServiceSoap = sAWSessionService.getSAWSessionServiceSoap();/*
                *try {*
                oracle.bi.web.soap.SAWSessionServiceSoapClient myPort = new oracle.bi.web.soap.SAWSessionServiceSoapClient();
                oracle.bi.web.soap.HtmlViewServiceClient htmlClient = new oracle.bi.web.soap.HtmlViewServiceClient();
                oracle.bi.web.soap.ReportEditingServiceSoapClient reportEdit = new oracle.bi.web.soap.ReportEditingServiceSoapClient();
                StartPageParams newPage = new StartPageParams();
                ReportRef newreportRef = new ReportRef();
                ReportParams newreportParams = new ReportParams();
                ReportHTMLOptions newreportHTMLOptions = new ReportHTMLOptions();
                newPage.dontUseHttpCookies = false;
                String sessionID = new String();
                String curUser = new String();
                String pageID = new String();
                String reportID = new String();
                String reportPath = new String();
                String reportXML = new String();
                String htmlOutput = new String();
                String bodyHTML = new String();
                String sqlResult = new String();
                sessionID = myPort.logon(“admin”,”admin”);
                curUser = myPort.getCurUser(sessionID);
                pageID = htmlClient.startPage(newPage,sessionID);
                System.out.println(“Page Id = “+ pageID+ “, sessionID = “+ sessionID);
                reportPath = “/shared/test/Report”;
                reportXML =”Report xml code”;
                *System.out.println(“Before report to page…”+”pageid =” pageID” reportid =”+reportID);*
                htmlClient.addReportToPage(pageID, reportID, newreportRef, null, null, null,sessionID);
                System.out.println(“Added report to page…”);
                htmlOutput = htmlClient.getHtmlForReport(pageID, reportID, sessionID);
                String headerHTML = htmlClient.getHeadersHtml(pageID, sessionID);
                bodyHTML = htmlClient.getCommonBodyHtml(pageID,sessionID);
                sqlResult = reportEdit.generateReportSQL(newreportRef,null,sessionID);
                System.out.println(“User:” + curUser);
                System.out.println(“PageID:” + pageID);
                *System.out.println(“HTML OUTPUT ” +htmlOutput);*
                System.out.println(“HTML OUTPUT DOne”);
                url = “”+htmlOutput + “”;
                FileOutputStream htmlFile, htmlFile1;
                *try {*
                htmlFile = new FileOutputStream (“myfile.html”);
                htmlFile1 = new FileOutputStream (“myfile1.html”);
                new PrintStream(htmlFile).println (htmlOutput);
                new PrintStream(htmlFile1).println (url);
                *// Catches any error conditions*
                catch (IOException e)
                System.err.println (“Unable to write to file”);
                Runtime.getRuntime().exec( “\”C:/Program Files/Mozilla Firefox/firefox.EXE\” \”file:///C:\\JDeveloper\\mywork\\SoapTest1\\Project1\\myfile1.html\”" );
                *catch (Exception ex) {*

                I am using obiee 11g and JDeveloper 11g release 1.
                Please help me for getting the report on html page..

                • 5. Re: OBIEE's Web Service SOAP-API + HtmlViewService + Access is Denied error
                  Hi There,

                  I am trying to do the exact same thing as you did, C# to read an OBIEE report and am having a hard time doing it. I have the app setup to use all of the WSDL services and I got the Handler setup as you showed in this post but I am not sure how to use it? Can you post your code on how you managed this?

                  Please help a fellow C# guy get along with the Oracle world...

                  • 6. Re: OBIEE's Web Service SOAP-API + HtmlViewService + Access is Denied error
                    Is anyone on the earth figured out Rotating Clock Issue? the problem is the javascript is missing for saw ondemandload.EmbedReport , the page can't find the javascript, I have a Servlet that spits out the HtmlViewService output to jsp page...

                    anyone out there?