In this section: |
This section provides code examples that demonstrate how to run the Sales_for_a_Specific_Country WebFOCUS report, which resides in the RESTful_Web_Services/Car_Reports folder. A successful sign-on request is a prerequisite for running this example, including retrieving the HTTP Header cookies from its response.
Imports System.Net
Imports System.IO
Imports System.Text
Dim request2 As HttpWebRequest
Dim response2 As HttpWebResponse
Dim webStream2 As Stream
Dim webResponse2 As String = ""
request2 =
WebRequest.Create("http://localhost:8080/ibi_apps/rs/ibfs/WFC/Repository/
RESTful_Web_Services/Car_Reports/Sales_for_a_Specific_Country.fex")
request2.Method = "POST"
'cookies is defined as CookieContainer in the Signing-On to WebFOCUS example
request2.CookieContainer = cookies
postData = "IBIRS_action=run&COUNTRY=ENGLAND"
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()
webStream2 = response2.GetResponseStream()
Dim webStreamReader2 As New StreamReader(webStream2)
While webStreamReader2.Peek >= 0
webResponse2 = webStreamReader2.ReadToEnd()
End While
WebBrowser1.DocumentText = webResponse2import java.awt.Frame;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
String request2 = "http://localhost:8080/ibi_apps/rs/ibfs/WFC/Repository/RESTful_Web_
Services/Car_Reports/Sales_for_a_Specific_Country.fex";
PostMethod method_report = new PostMethod(request2);
method_report.addParameter("IBIRS_action","run");
method_report.addParameter("COUNTRY","ENGLAND");
// cookies is defined as Header[] in the Signing-On to WebFOCUS example
for(int h=0; h<cookies.length; h++){
System.out.println(cookies[h]);
method_report.addRequestHeader(cookies[h].getName(), cookies[h].getValue());
}
// client is defined as HttpClient in the Signing-On to WebFOCUS example
int statusCode2 = client.executeMethod(method_report);
InputStream rstream2 = null;
rstream2 = method_report.getResponseBodyAsStream();
File tempfile = new File("c:\\temp\\Report.htm");
FileOutputStream fos = new FileOutputStream(tempfile);
PrintWriter out=new PrintWriter(fos);
BufferedReader br2 = new BufferedReader(new InputStreamReader(rstream2));
String line2;
String newOutput = null;
while ((line2 = br2.readLine()) != null) {
newOutput = line2;
out.println(newOutput);
System.out.println(line2);
}
br2.close();
out.close();| Information Builders |