Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace crystalasWebService
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
public string strResult2;
public Stream stream;
protected void Button1_Click(object sender, EventArgs e)
{


CrystalReportService crs = new CrystalReportService();
DataSet ds = new DataSet();

ds = CallGetMethod();
crs.SetDataSource(ds);
CrystalReportViewer1.ReportSource = "CrystalReportService.rpt";
}
public DataSet CallGetMethod()
{
// Restful service URL
string url = "http://localhost:53732/CrystalService.svc/GetTableData/list";
DataSet strResult = new DataSet();
// declare httpwebrequet wrt url defined above
HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url);
// set method as post
webrequest.Method = "GET";
// set content type
webrequest.ContentType = "application/xml";
// declare & read response from service
HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
// set utf8 encoding
Encoding enc = System.Text.Encoding.GetEncoding("utf-8");
// read response stream from response object
StreamReader loResponseStream = new StreamReader
(webresponse.GetResponseStream(), enc);
// read string from stream data
strResult2 = loResponseStream.ReadToEnd();

// close the stream object
loResponseStream.Close();
// close the response object
webresponse.Close();
// assign the final result to text box
//txtResult.Text = strResult;
return strResult;
}
}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900