In this section: |
This section provides code examples that demonstrate how to run an On-Demand Paging report called ODP_Report.fex, which resides in the RESTful_Web_Services/Car_Reports folder.
The examples include:
The WebForm2 page can also be used as is to handle Drill-down and Active Cache paging requests.
The signOn page contains the RESTful Web Service request to run the initial WebFOCUS report. The IBIRS_clientPath parameter is set so that all additional RESTful Web Services requests needed, whether paging, image retrieval, or paging will be routed through the client application. For example:
IBIRS_clientPath=http://localhost:51970/WebForm2.aspx
Imports System.Net Imports System.IO Public Class signOn Inherits System.Web.UI.Page Dim cookies As New CookieContainer Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim webStream As Stream Dim webResponse As String = "" Dim request As HttpWebRequest Dim response1 As HttpWebResponse Dim postData As String request = WebRequest.Create("http://localhost.:8080/ibi_apps/rs/ibfs") request.Method = "POST" postData = "IBIRS_action=signOn&IBIRS_userName=admin&IBIRS_password=admin" request.CookieContainer = cookies Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData) request.ContentType = "application/x-www-form-urlencoded" request.ContentLength = byteArray.Length Dim dataStream As Stream = request.GetRequestStream() dataStream.Write(byteArray, 0, byteArray.Length) dataStream.Close() response1 = request.GetResponse() webStream = response1.GetResponseStream() Dim request2 As HttpWebRequest Dim response2 As HttpWebResponse Dim webStream2 As Stream Dim webResponse2 As String = "" Dim uri As New System.Uri("http://localhost.:8080/ibi_apps/rs") request2 = WebRequest.Create(uri) request2.Method = "POST" request2.CookieContainer = cookies postData = "IBIRS_action=run" + _ "&IBIRS_clientPath=http://localhost:51970/WebForm2.aspx" + _ "&IBIRS_path=/WFC/Repository/RESTful_Web_Services/Car_Reports/ODP_Report.fex" + _ "&IBIRS_service=ibfs" + _ "&IBIRS_htmlPath=http://localhost:8080/ibi_apps/ibi_html" Dim byteArray2 As Byte() = Encoding.UTF8.GetBytes(postData) request2.ContentType = "application/x-www-form-urlencoded"
request2.ContentLength = byteArray2.Length Dim dataStream2 As Stream = request2.GetRequestStream() dataStream2.Write(byteArray2, 0, byteArray2.Length) dataStream2.Close() response2 = request2.GetResponse() Dim i As Integer Dim cookieArray As New CookieCollection cookieArray = cookies.GetCookies(uri) For i = 0 To cookies.Count - 1 Dim aCookie As New HttpCookie(cookieArray(i).Name) aCookie.Value = cookieArray(i).Value Response.Cookies.Add(aCookie) Next i webStream2 = response2.GetResponseStream() Dim webStreamReader2 As New StreamReader(webStream2) While webStreamReader2.Peek >= 0 webResponse2 = webStreamReader2.ReadToEnd() End While Response.Output.Write(webResponse2) End Sub End Class
Imports System.Net Imports System.IO Public Class WebForm2 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim tDrillURL As String = "" Dim i As Integer Dim qParm As String Dim qValue As String Dim IBIRS_path As String = "" Dim Clicked_On As String = "" Dim cookies As New CookieContainer If Request.QueryString.AllKeys.Length = 0 Then For i = 0 To Request.Form.AllKeys.Length - 1 qValue = Request.Form(Request.Form.AllKeys(i)) If i = 0 Then tDrillURL = tDrillURL + Request.Form.AllKeys(i) + "=" + qValue Else tDrillURL = tDrillURL + "&" + Request.Form.AllKeys(i) + "=" + qValue End If Next i Else For i = 0 To Request.QueryString.AllKeys.Length - 1 qParm = Request.QueryString.AllKeys(i) qValue = Request.QueryString(Request.QueryString.AllKeys(i)) If i = 0 Then If Request.QueryString.AllKeys(i) <> Nothing Then tDrillURL = tDrillURL + Request.QueryString.AllKeys(i) + "=" + qValue End If Else tDrillURL = tDrillURL + "&" + Request.QueryString.AllKeys(i) + "=" + qValue End If Next i End If Dim request3 As HttpWebRequest Dim response3 As HttpWebResponse Dim webStream3 As Stream Dim webResponse3 As String = "" Dim getData As String Dim uris As String = "http://localhost.:8080/ibi_apps/rs/ibfs"
Dim uri As New System.Uri(uris) getData = "http://localhost.:8080/ibi_apps/rs/ibfs?" + _ tDrillURL + _ "&IBIRS_clientPath=http://localhost:51970/WebForm2.aspx" + _ "&IBIRS_htmlPath=http://localhost:8080/ibi_apps/ibi_html" request3 = WebRequest.Create(getData) request3.Method = "GET" Dim j As Integer For j = 0 To Request.Cookies.Count - 1 Dim rCookie As New System.Net.Cookie rCookie.Name = Request.Cookies(j).Name rCookie.Value = Request.Cookies(j).Value cookies.Add(uri, rCookie) Dim aCookie As New HttpCookie(Request.Cookies(j).Name) aCookie.Value = Request.Cookies(j).Value Response.Cookies.Add(aCookie) Next j request3.CookieContainer = cookies response3 = request3.GetResponse() webStream3 = response3.GetResponseStream() Dim binaryReader3 As New BinaryReader(webStream3) Dim readData() As Byte = Nothing Dim byteArray() As Byte = Nothing Dim byteStart As Integer = 0 Dim byteLength As Integer While (True) readData = binaryReader3.ReadBytes(4096) If (readData.Length = 0) Then Exit While End If byteLength = readData.Length ReDim Preserve byteArray(byteLength + byteStart - 1) Array.Copy(readData, 0, byteArray, byteStart, byteLength) byteStart = byteStart + byteLength End While Response.OutputStream.Write(byteArray, 0, byteArray.Length) End Sub End Class
WebFOCUS |