Quantcast
Channel: SCN : Popular Discussions - RESTful Web Services SDK
Viewing all articles
Browse latest Browse all 1088

Retrieve the report content for display using RESTful Services

$
0
0

Hi All,

 

I am using the CR for Enterprise to build report. So far as I knew. the report from CR for Enterprise can't be opened with either of the SDK's, .NET or Java.

Otherwise I will got error with 'Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.".

 

so firstly I have to deploy the report to CR Server 2013 of SAP BI.

Now I am trying to build a .Net application to view these report.

 

So far I have tried the below ways. But doesn't get it through . Please help to review it .

 

1. RESTful doesn't matter with what language we build for the application. so I believe this is the right choice to go .

 

So I logon the RESTful Services, and try to use the export services. but didn't make it .

What get me stuck with is I can't get correct RESTful url for the specified RESTful services.

I can logon with the url "http://<servername>:6405/biprws/logon/long".

and I can retrieve the reports information under a specified folder with the url  "http://<servername>:6405/biprws/infostore/<folderid>/children/"

and also can retrieve a specified report information with the url "http://<servername>:6405/biprws/infostore/<reportid>"

 

But I can't view a report with the format like PDF.

I tried these urls below

"http://<baseURI>/infostore/<reportID>/rpt/export?mime_type=application/PDF".(get error 404)

"http://<baseURI>/raylight/v1/documents/<reportID>".(get error 404)

"http://<baseURI>/infostore/<reportID>".(the reponse doesn't support the accept type)

 

the code looks like below:

            ....

            WebRequest myWebRequest = WebRequest.Create(LogonURI);

            myWebRequest.ContentType = "application/xml";

            myWebRequest.Method = "GET";

            //Returns the response to the request made

            WebResponse myWebResponse = myWebRequest.GetResponse();

            //Creating an instance of StreamReader to read the data stream from the resource

            StreamReader sr = new StreamReader(myWebResponse.GetResponseStream());

            //Reads all the characters from the current position to the end of the stream and store it as string

            string output = sr.ReadToEnd();

            //Initialize a new instance of the XmlDocument class

            XmlDocument doc = new XmlDocument();

            //Loads the document from the specified URI

            doc.LoadXml(output);

            //Returns an XmlNodeList containing a list of all descendant elements

            //that match the specified name i.e. attr

            XmlNodeList nodelist = doc.GetElementsByTagName("attr");

            //  Add the logon parameters to the attribute nodes of the document

            foreach (XmlNode node in nodelist)

            {

                if (node.Attributes["name"].Value == "userName")

                    node.InnerText = userName;

                if (node.Attributes["name"].Value == "password")

                    node.InnerText = password;

                if (node.Attributes["name"].Value == "auth")

                    node.InnerText = auth;

            }

            //Making POST request to /logon/long to receive a logon token

            WebRequest myWebRequest1 = WebRequest.Create(LogonURI);

            myWebRequest1.ContentType = "application/xml";

            myWebRequest1.Method = "POST";

            byte[] reqBodyBytes = System.Text.Encoding.Default.GetBytes(doc.OuterXml);

            Stream reqStream = myWebRequest1.GetRequestStream();

            reqStream.Write(reqBodyBytes, 0, reqBodyBytes.Length);

            reqStream.Close();

            try

            {

                WebResponse myWebResponse1 = myWebRequest1.GetResponse();

                 rwsLogonToken = myWebResponse1.Headers["X-SAP-LogonToken"].ToString();

                HttpWebRequest myWebRequest2 = (HttpWebRequest)WebRequest.Create(InfoStoreURI);

                myWebRequest2.Accept = "application/PDF";

                myWebRequest2.Headers.Add("X-SAP-LogonToken", rwsLogonToken);

                myWebRequest2.Method = "GET";

                WebResponse myWebResponse2 = myWebRequest2.GetResponse();

                FileStream stream = new FileStream(Request.PhysicalApplicationPath + "output.pdf", FileMode.Create);

                Stream pdfStream = null;

                using (pdfStream = myWebResponse2.GetResponseStream())

                {

                    pdfStream.CopyTo(stream);

                }

                stream.Close();

                Response.Redirect("output.pdf");

            }

            catch (WebException ex)

            {

                //error while accessing the network through a pluggable protocol

                Response.Write("<b>" + ex.Message + "</b>");

            }

            catch (Exception ex)

            {

                //generic error

                Response.Write("<b>" + ex.Message + "</b>");

            }

            ....

 

and I try to get all the documents with url "http://<baseURI>/raylight/v1/documents".

but seems I did't get any available document to use.

the response xml content is below.

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<documents/>

 

 

2. OpenDocument also doesn't matter with the language specification. so it is also a good choice.

So I followed this article http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=314933510 and  Trying to use the openDocument url to view the reports. in this way I can view the report but have another problem !

The report has some parameters(please review the attachment) . I don't know how to pass these parameters by the url. I read through the openDocument guide http://help.sap.com/businessobject/product_guides/boexir4/en/xi4_opendocument_en.pdf. But didn't found a way to make it . Please help me to get out of this situation. Thanks.


Viewing all articles
Browse latest Browse all 1088

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>