加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

在后面的asp.net代码中使用web服务的最佳方法

发布时间:2020-12-16 07:42:39 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试将数据源绑定到转发器,例如,在页面加载时绑定到Web服务(来自不同网站的.asmx). webservice从sql调用返回一个DataSet.这样做的最佳方法是什么? 解决方法 因为您正在呼叫另一个网站,所以您必须应对两个问题(特别是如果此Web服务位于其他人的网站上
我正在尝试将数据源绑定到转发器,例如,在页面加载时绑定到Web服务(来自不同网站的.asmx). webservice从sql调用返回一个DataSet.这样做的最佳方法是什么?

解决方法

因为您正在呼叫另一个网站,所以您必须应对两个问题(特别是如果此Web服务位于其他人的网站上或通过公共互联网).首先,从其他网站检索数据可能会有延迟.其次,其他网站可能会超时.

至少您应该考虑asychronous page请求.正如这篇MSDN文章所述:

If a synchronous request becomes I/O
bound—for example,if it calls out to
a remote Web service or queries a
remote database and waits for the call
to come back—then the thread assigned
to the request is stuck doing nothing
until the call returns. That impedes
scalability because the thread pool
has a finite number of threads
available. If all request-processing
threads are blocked waiting for I/O
operations to complete,additional
requests get queued up waiting for
threads to be free. At best,
throughput decreases because requests
wait longer to be processed. At worst,
the queue fills up and ASP.NET fails
subsequent requests with 503 “Server
Unavailable” errors.

但最好的解决方案可能是使用AJAX.加载页面然后发出ajax请求以填充转发器.这样,当您在Web服务上等待时,您可以获得漂亮的“旋转”图形或其他正在发生的事情.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读