Webservice - executiontimeout和sendtimeout-receivetimeout-closetimeout和opentimeout的区别?
Webservice - executiontimeout and sendtimeout-receivetimeout-closetimeout and opentimeout difference?
我正在尝试调用 ASMX 网络服务。
执行超时为 600,即 Web.Config 中的 10 分钟。
调试为假。
在绑定中 - 我编写了以下代码:
<binding name="BasicHttpBinding_AdminService" openTimeout="00:20:00" closeTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
尽管服务需要 20 分钟 -- 我在 10 分钟内从服务器收到请求超时。我认为连接将在 10 分钟后被服务器切断。
我只需要通过代码来完成 -- 无需更改 Config 中的任何内容。我不想更改 executiontimeout="600".
<httpRuntime maxRequestLength="512000" executionTimeout="600" enableKernelOutputCache="false" />
我通过代码尝试了以下方法:
var times = new TimeSpan(0, 20, 0);
1) ((IContextChannel)adminService.InnerChannel).OperationTimeout = new TimeSpan(0, 20, 0);
2) adminService.InnerChannel.OperationTimeout = times;
3) adminService.Endpoint.Binding.SendTimeout = times;
adminService.Endpoint.Binding.ReceiveTimeout = times;
adminService.Endpoint.Binding.CloseTimeout = times;
adminService.Endpoint.Binding.OpenTimeout = times;
4) adminService.ChannelFactory.Endpoint.Binding.CloseTimeout = times;
adminService.ChannelFactory.Endpoint.Binding.OpenTimeout = times;
adminService.ChannelFactory.Endpoint.Binding.ReceiveTimeout = times;
adminService.ChannelFactory.Endpoint.Binding.SendTimeout = times;
但是 none 有所帮助。我也尝试使用异步调用,但没有成功。
有什么我遗漏的吗?
我在服务器的响应中得到以下信息:
ManagedPoolThread #8 06:52:05 ERROR Error in Feed via WebService
Exception: System.ServiceModel.ProtocolException
Message: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<!--[if !IE 9]><!-->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!--><![endif]-->
<!--[if IE 9]><meta http-equiv="X-UA-Compatible" content="IE=9"><![endif]-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, maximum-scale=1.0;">
<link href="/bundles/Styles?v=i3oWdxitwv-nVHzTzh8-q4ehRZVNWjvCP15tgDwz3hI1" rel="stylesheet"/>
<script src="/ISites/_Themes/ICom2013/_Design/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<script src="/ISites/_Themes/ICom2013/_Design/js/vendor/jquery-1.11.1.js"></script>
<!-- Global for all sites-->
<!-- Favicons for all'.
Source: mscorlib
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at I.WCMS.BLL.AdminServiceReference.AdminServiceSoap.GetGenderFeed(GetGenderFeedRequest request)
at I.WCMS.BLL.AdminServiceReference.AdminServiceSoapClient.I.WCMS.BLL.AdminServiceReference.AdminServiceSoap.GetGenderFeed(GetGenderFeedRequest request)
at I.WCMS.BLL.AdminServiceReference.AdminServiceSoapClient.GetGenderFeed(String siteRoot, String securedString)
at I.WCMS.Feeds.FeedTaskCommand.GenerateFeeds()
我在服务器上得到以下异常:
8672 07:02:05 ERROR Error in Admin Service for generating Feed
8672 07:02:05 ERROR Application error.
Exception: System.Web.HttpException
Message: Request timed out.
为什么更改绑定中的超时不起作用?
为什么服务请求在 10 分钟内从服务器超时?
执行超时是否等于或大于绑定超时设置?
做了很多研究,终于找到了解决方案。
由于 Webservice 位于另一个目录中,因此最好的解决方案是创建另一个 web.config 并更改特定服务请求的执行超时。
解决方案:Raise the time-out for a single webservice
我正在尝试调用 ASMX 网络服务。
执行超时为 600,即 Web.Config 中的 10 分钟。 调试为假。 在绑定中 - 我编写了以下代码:
<binding name="BasicHttpBinding_AdminService" openTimeout="00:20:00" closeTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
尽管服务需要 20 分钟 -- 我在 10 分钟内从服务器收到请求超时。我认为连接将在 10 分钟后被服务器切断。
我只需要通过代码来完成 -- 无需更改 Config 中的任何内容。我不想更改 executiontimeout="600".
<httpRuntime maxRequestLength="512000" executionTimeout="600" enableKernelOutputCache="false" />
我通过代码尝试了以下方法:
var times = new TimeSpan(0, 20, 0);
1) ((IContextChannel)adminService.InnerChannel).OperationTimeout = new TimeSpan(0, 20, 0);
2) adminService.InnerChannel.OperationTimeout = times;
3) adminService.Endpoint.Binding.SendTimeout = times;
adminService.Endpoint.Binding.ReceiveTimeout = times;
adminService.Endpoint.Binding.CloseTimeout = times;
adminService.Endpoint.Binding.OpenTimeout = times;
4) adminService.ChannelFactory.Endpoint.Binding.CloseTimeout = times;
adminService.ChannelFactory.Endpoint.Binding.OpenTimeout = times;
adminService.ChannelFactory.Endpoint.Binding.ReceiveTimeout = times;
adminService.ChannelFactory.Endpoint.Binding.SendTimeout = times;
但是 none 有所帮助。我也尝试使用异步调用,但没有成功。
有什么我遗漏的吗?
我在服务器的响应中得到以下信息:
ManagedPoolThread #8 06:52:05 ERROR Error in Feed via WebService
Exception: System.ServiceModel.ProtocolException
Message: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<!--[if !IE 9]><!-->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!--><![endif]-->
<!--[if IE 9]><meta http-equiv="X-UA-Compatible" content="IE=9"><![endif]-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, maximum-scale=1.0;">
<link href="/bundles/Styles?v=i3oWdxitwv-nVHzTzh8-q4ehRZVNWjvCP15tgDwz3hI1" rel="stylesheet"/>
<script src="/ISites/_Themes/ICom2013/_Design/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<script src="/ISites/_Themes/ICom2013/_Design/js/vendor/jquery-1.11.1.js"></script>
<!-- Global for all sites-->
<!-- Favicons for all'.
Source: mscorlib
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at I.WCMS.BLL.AdminServiceReference.AdminServiceSoap.GetGenderFeed(GetGenderFeedRequest request)
at I.WCMS.BLL.AdminServiceReference.AdminServiceSoapClient.I.WCMS.BLL.AdminServiceReference.AdminServiceSoap.GetGenderFeed(GetGenderFeedRequest request)
at I.WCMS.BLL.AdminServiceReference.AdminServiceSoapClient.GetGenderFeed(String siteRoot, String securedString)
at I.WCMS.Feeds.FeedTaskCommand.GenerateFeeds()
我在服务器上得到以下异常:
8672 07:02:05 ERROR Error in Admin Service for generating Feed
8672 07:02:05 ERROR Application error.
Exception: System.Web.HttpException
Message: Request timed out.
为什么更改绑定中的超时不起作用?
为什么服务请求在 10 分钟内从服务器超时?
执行超时是否等于或大于绑定超时设置?
做了很多研究,终于找到了解决方案。 由于 Webservice 位于另一个目录中,因此最好的解决方案是创建另一个 web.config 并更改特定服务请求的执行超时。
解决方案:Raise the time-out for a single webservice