我公司运行与被写在C#/ ASP.Net Web服务的问题。该服务接收在SQL Server中,并生成和保存PDF报告,该数据的路径数据的身份密钥。

在大多数情况下,Web服务将结果返回到调用网页的速度非常快,通常在几秒钟最大。

但是,似乎偶尔打一个显著放缓。当这种放缓出现的Web应用程序调用Web服务将产生超时错误。我们已经检查和PDF不会获取创建并保存到服务器上,所以它看起来像Web服务,最终完成执行。这似乎为已经完成处理需时约1至2分钟。 PDF格式的使用从数据动态生成的ActiveReports。

w当出现此问题,使得小的变化,以Web服务的配置文件(即,添加一个空格的连接字符串线)似乎重新启动Web服务,一切是一段时间完全确定之后。

这是在同一个Web服务器上运行的其他Web应用程序似乎并没有遇到这种类型的行为,只有这个特定的Web服务。

我已经添加了下面的web服务的代码。这是第三方库基本通话费。我们不能够重新测试该问题。

我想知道什么可能导致这个问题?

[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";
}
有帮助吗?

解决方案

Just a short note: You're not disposing your StreamWriter and maybe there are other disposable objects in your service, too. This could cause a memory leak in your app which could lead IIS to restart your worker process. Even though this probably won't be the solution to your problem, disposing disposable objects will help to prevent future problems!

其他提示

You're going to have to debug IIS when this happens to see where the true problem lies.

You should use the IIS Debug Diagnostics Tool to help you determine what's happening.

I would also read Tess Ferrandez's blog on debugging IIS problems.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top