CLR Web 服务调用在 100 秒时超时

发布于 2024-10-31 04:07:02 字数 2062 浏览 3 评论 0原文

我在任何地方都没有找到这个答案。我有一个 CLR 函数,可以执行 .NET 应用程序 (.asmx) 的 webmethod 调用。直接调用时,Web 服务成功执行,但通过 CLR 调用时,它会在 100 秒后超时,并出现以下错误:

Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "fn_ExecuteReport":
System.Net.WebException: The operation has timed out
System.Net.WebException:
   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at DD.WebServices.WebExec.ExecuteReport(String ddBotID, String serverKey, Int32 ddUserID, String reportReportTypeList, String deliverToUserList)
   at ExecuteReport.GetResult(Int32 userID, SqlString reportList, SqlString deliverToUserList)

我在 fn_ExecuteReport 中增加了 Web 服务代理超时,但没有效果:

WebExec svc = new WebExec();<br/>
svc.Timeout = 3600000;  // set timeout to 1 hour<br/>
result = svc.ExecuteReport(userID, reportTypeList.ToString(),
                           deliverToUserList.ToString());

我想捕获返回的结果,因此异步执行 Web 服务不是一个解决方案。我还可以在哪里覆盖 SQL CLR 调用的超时设置?感谢您提供的任何帮助。

这是该函数的代码。我能够执行 Web 服务,只有通过 CLR 执行时才会发生超时。

ALTER FUNCTION [dbo].[fn_ExecuteReport]
(@UserID int, @ReportTypeList nvarchar(max), @DeliverToUserList nvarchar(max)) 
RETURNS [nvarchar](255) 
WITH EXECUTE AS CALLER AS EXTERNAL NAME [MyCLRLib].[ExecuteReport].[GetResult] 

我已尝试在 CLR 函数中对 Web 服务进行同步和异步调用,但最终都以 100 秒超时结束。这是我尝试过的两个调用:

同步:
WebExec svc = new WebExec(); svc.超时= 3600000; // 设置超时时间为1小时 result = svc.ExecuteReport(userID, reportTypeList.ToString(), DeliverToUserList.ToString());

异步:
WebExec svc = new WebExec();
IAsyncResult 结果 = svc.BeginExecuteReport(userID, reportTypeList.ToString(), DeliverToUserList.ToString(), null, null);
结果.AsyncWaitHandle.WaitOne();
retStr = svc.EndExecuteReport(结果);

I have not found this answered anywhere. I have a CLR function that exectues a webmethod call of my .NET application (.asmx). The web service successfully executes when called directly but when called via the CLR it times out after 100 seconds with the following error:

Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "fn_ExecuteReport":
System.Net.WebException: The operation has timed out
System.Net.WebException:
   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at DD.WebServices.WebExec.ExecuteReport(String ddBotID, String serverKey, Int32 ddUserID, String reportReportTypeList, String deliverToUserList)
   at ExecuteReport.GetResult(Int32 userID, SqlString reportList, SqlString deliverToUserList)

I have increased the web service proxy timeout in fn_ExecuteReport without effect:

WebExec svc = new WebExec();<br/>
svc.Timeout = 3600000;  // set timeout to 1 hour<br/>
result = svc.ExecuteReport(userID, reportTypeList.ToString(),
                           deliverToUserList.ToString());

I want to capture the returned result so executing the webservice asynchronously is not a solution. Where else might I override timeout settings for the SQL CLR call? Thanks for any help you can provide.

Here's the code for the function. I'm able to execute the webservice, the timeout only occurs when executing via the CLR.

ALTER FUNCTION [dbo].[fn_ExecuteReport]
(@UserID int, @ReportTypeList nvarchar(max), @DeliverToUserList nvarchar(max)) 
RETURNS [nvarchar](255) 
WITH EXECUTE AS CALLER AS EXTERNAL NAME [MyCLRLib].[ExecuteReport].[GetResult] 

I've tried both synchronous and asynchronous calls to the web service in the CLR function and both end up with the 100 second timeout. Here's both calls that I've tried:

Synchronous:
WebExec svc = new WebExec();
svc.Timeout = 3600000; // set timeout to 1 hour
result = svc.ExecuteReport(userID, reportTypeList.ToString(), deliverToUserList.ToString());

Asynchronous:
WebExec svc = new WebExec();
IAsyncResult result = svc.BeginExecuteReport(userID, reportTypeList.ToString(), deliverToUserList.ToString(), null, null);
result.AsyncWaitHandle.WaitOne();
retStr = svc.EndExecuteReport(result);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

留蓝 2024-11-07 04:07:02

您的错误消息表明超时源于 SQL Server。

您是否尝试过更新 SQL Server 统计信息(或重建索引)?

你能发布你的CLR函数的代码吗?

Your error message suggests that the timeout is originating at SQL Server.

Have you tried updating your SQL Server statistics (or rebuilding indexes)?

Can you post the code of your CLR function?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文