My company is running into a problem with a web service that is written in C#/ASP.Net. The service receives an identity key for data in SQL Server and a path to generate and save a PDF report for this data.
In most cases, this web service returns results to the calling web pages very quickly, usually within a few seconds max.
However, it seems to occasionally hit a significant slowdown. The web application calling the web service will generate a timeout error when this slowdown occurs. We have checked and the PDF does get created and saved to the server, so it looks like the web service eventually finishes executing. It seems to take about 1 to 2 minutes for processing to have completed. The PDF is generated using ActiveReports from Data Dynamics.
Wwhen this problem occurs, making a small change to the web service's config file (ie, adding a blank space to a connection string line) seems to restart the web service and everything is perfectly ok for a period of time afterwards.
Other web applications that are running on the same web server do not seem to experience this type of behavior, only this particular web service.
I have added the code for the web service below. It is basic calls to 3rd party libraries. We are not able to recreate this problem in test.
I am wondering what might be causing this issue?
[WebMethod]
public string Publish(int identity, string transactionType, string directory, string filename)
{
try
{
AdpConnection Conn = new AdpConnection(ConfigurationManager.AppSettings["myDBConnString"]);
AdpCommand Cmd = new AdpCommand("storedproc_GetData", oConn);
AdpParameter Param;
Cmd.CommandType = CommandType.StoredProcedure;
Param = Cmd.CreateParameter("@Identity", DbType.Int32);
Param.Value = identity;
Cmd.Parameters.Add(oParam);
Conn.Open();
string aResponse = Cmd.ExecuteScalar().ToString();
Conn.Close();
if (transactionType == "typeA")
{
//Parse response
DataSet dsResponse = ParseDataResponse(aResponse);
//dsResponse.WriteXml(@ConfigurationManager.AppSettings["DocsDir"] + identity.ToString() + ".xml");
DataDynamics.ActiveReports.ActiveReport3 rpt = new DataDynamics.ActiveReports.ActiveReport3();
rpt.LoadLayout(@ConfigurationManager.AppSettings["myReportPath"] + "TypeA.rpx");
rpt.AddNamedItem("ReportPath", @ConfigurationManager.AppSettings["myReportPath"]);
rpt.AddNamedItem("XMLSTRING", FormatXML(dsResponse.GetXml()));
DataDynamics.ActiveReports.DataSources.XMLDataSource xmlds = new DataDynamics.ActiveReports.DataSources.XMLDataSource();
xmlds.FileURL = null;
xmlds.RecordsetPattern = "//DataPatternA";
xmlds.LoadXML(FormatXML(dsResponse.GetXml()));
if (!System.IO.Directory.Exists(@ConfigurationManager.AppSettings["DocsDir"] + directory + @"\"))
{
System.IO.Directory.CreateDirectory(@ConfigurationManager.AppSettings["DocsDir"] + directory + @"\");
}
string sXML = FormatXML(dsResponse.GetXml());
StreamWriter sw = new StreamWriter(@ConfigurationManager.AppSettings["DocsDir"] + directory + @"\" + filename + ".xml", false);
sw.Write(sXML);
sw.Close();
rpt.DataSource = xmlds;
rpt.Run(true);
DataDynamics.ActiveReports.Export.Pdf.PdfExport xPdf = new DataDynamics.ActiveReports.Export.Pdf.PdfExport();
xPdf.Export(rpt.Document, @ConfigurationManager.AppSettings["DocsDir"] + directory + @"\" + filename + ".pdf");
}
}
catch(Exception ex)
{
return "Error: " + ex.ToString();
}
return @ConfigurationManager.AppSettings["DocsDir"] + directory + @"\" + filename + ".pdf";
}