aspnetdev
asked on
Error in Sql Server 2005 Webservice --Client found response content type of 'text/html', but expected 'text/xml'
Hi,
I have a asp.net web page which has 3 dropdown list and a radio button plus a button.User select relevant values from the dropdowns,check the radio button if needed and click go button.Actually it calls a Sql server 2005 Reportiing web service and passes the parameters using this web service and renders report.But,im having problem rendering this report....i want to render in pdf format ....and heres my code
private void btnGO_Click(object sender, System.EventArgs e)
{
GetReport();
}
private void GetReport()
{
ReportExecutionService rsExec = GetReportExecutionService( );
bool forRendering = false;
string extension = string.Empty;
string mimeType = string.Empty;
string encoding = string.Empty;
string[] streamIDs = null;
Web.ReportExecution2005.Wa rning[] warnings = null;
string reportName = ConfigurationSettings.AppS ettings["R eportExecu tion2005.R eportsFold er"] + "/" +"Report"+ ddlReport.SelectedItem.Tex t;
Response.ContentType = "application/pdf";
Response.AddHeader("conten t-disposit ion", "attachment;filename=" + ddlReport.SelectedItem.Tex t + ".pdf");
rsExec.LoadReport(reportNa me,null); //here where i hit the problem
Web.ReportExecution2005.Pa rameterVal ue[] parameters = new Web.ReportExecution2005.Pa rameterVal ue[4];
parameters[0] = new Web.ReportExecution2005.Pa rameterVal ue();
parameters[0].Label = "clientId";
parameters[0].Name = "clientId";
if(!chkByT.Checked)
{
parameters[0].Value = 1
}
else
{
parameters[0].Value = "-1";
}
parameters[2] = new Web.ReportExecution2005.Pa rameterVal ue();
parameters[2].Label = "Year";
parameters[2].Name = "Year";
parameters[2].Value = ddlYear.SelectedItem.ToStr ing();
parameters[3] = new Web.ReportExecution2005.Pa rameterVal ue();
parameters[3].Label = "Qtr";
parameters[3].Name = "Qtr";
parameters[3].Value = ddlQtr.SelectedValue.ToStr ing();
parameters[4] = new Web.ReportExecution2005.Pa rameterVal ue();
parameters[4].Label = "Annual";
parameters[4].Name = "Annual";
if(radYearly.Checked)
{
parameters[4].Value = "1";
}
else
{
parameters[4].Value = "0";
}
rsExec.SetExecutionParamet ers(parame ters,"en-u s");
Byte[] bytes = rsExec.Render("PDF",null,o ut extension,out mimeType,out encoding,out warnings,out streamIDs);
Response.BinaryWrite(bytes );
Response.Flush();
Response.End();
}
and the error im getting is
Client found response content type of 'text/html', but expected 'text/xml'. The request failed with the error message: -- <html><head><title>Error</ title></he ad><body>T he specified procedure could not be found. </body></html> --.
I have a asp.net web page which has 3 dropdown list and a radio button plus a button.User select relevant values from the dropdowns,check the radio button if needed and click go button.Actually it calls a Sql server 2005 Reportiing web service and passes the parameters using this web service and renders report.But,im having problem rendering this report....i want to render in pdf format ....and heres my code
private void btnGO_Click(object sender, System.EventArgs e)
{
GetReport();
}
private void GetReport()
{
ReportExecutionService rsExec = GetReportExecutionService(
bool forRendering = false;
string extension = string.Empty;
string mimeType = string.Empty;
string encoding = string.Empty;
string[] streamIDs = null;
Web.ReportExecution2005.Wa
string reportName = ConfigurationSettings.AppS
Response.ContentType = "application/pdf";
Response.AddHeader("conten
rsExec.LoadReport(reportNa
Web.ReportExecution2005.Pa
parameters[0] = new Web.ReportExecution2005.Pa
parameters[0].Label = "clientId";
parameters[0].Name = "clientId";
if(!chkByT.Checked)
{
parameters[0].Value = 1
}
else
{
parameters[0].Value = "-1";
}
parameters[2] = new Web.ReportExecution2005.Pa
parameters[2].Label = "Year";
parameters[2].Name = "Year";
parameters[2].Value = ddlYear.SelectedItem.ToStr
parameters[3] = new Web.ReportExecution2005.Pa
parameters[3].Label = "Qtr";
parameters[3].Name = "Qtr";
parameters[3].Value = ddlQtr.SelectedValue.ToStr
parameters[4] = new Web.ReportExecution2005.Pa
parameters[4].Label = "Annual";
parameters[4].Name = "Annual";
if(radYearly.Checked)
{
parameters[4].Value = "1";
}
else
{
parameters[4].Value = "0";
}
rsExec.SetExecutionParamet
Byte[] bytes = rsExec.Render("PDF",null,o
Response.BinaryWrite(bytes
Response.Flush();
Response.End();
}
and the error im getting is
Client found response content type of 'text/html', but expected 'text/xml'. The request failed with the error message: -- <html><head><title>Error</
What happen if you clear the headers of your page before assiginng "application/pdf"?
hmm; reading the error message returned
>> The specified procedure could not be found <<
implies that a procedure that the report is based on/uses is not in the database??!!
put some try ... catch statements round rsExec.Render to see if that is place where code fails.
/Richard
>> The specified procedure could not be found <<
implies that a procedure that the report is based on/uses is not in the database??!!
put some try ... catch statements round rsExec.Render to see if that is place where code fails.
/Richard
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.