我正在尝试调用ASMX Web服务。
执行超时为600,即Web.Config中的10分钟。 调试是错误的。 在Binding中 - 我写了以下代码:
<httpRuntime maxRequestLength="512000" executionTimeout="600" enableKernelOutputCache="false" />
虽然它是20分钟的服务 - 我在10分钟内从服务器获得请求超时。我认为连接在10分钟内被服务器切断了。
我需要通过Code代码完成 - 不需要在Config中更改任何内容。我不想改变executiontimeout =&#34; 600&#34;。
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;
我通过以下方式尝试使用Code:
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()
但没有人帮忙。我也尝试过Async Call,但没有运气。
我有什么遗失的吗?
我在服务器响应中得到以下内容:
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.
我在服务器上得到以下异常:
private void checkPermission() {
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_PHONE_STATE)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_PHONE_STATE)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.READ_PHONE_STATE},
MY_PERMISSIONS_REQUEST_READ_PHONE_STATE);
// MY_PERMISSIONS_REQUEST_READ_PHONE_STATE is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_READ_PHONE_STATE: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, yay! Do the
// contacts-related task you need to do.
} else {
// permission denied, boo! Disable the
// functionality that depends on this permission.
}
return;
}
// other 'case' lines to check for other
// permissions this app might request
}
}
为什么更改绑定中的超时不起作用?
为什么服务请求会在10分钟内从服务器获得超时?
executionTimeout是否等于或大于绑定超时设置?
答案 0 :(得分:2)
经过大量研究并最终得到了解决方案。 由于Webservice位于另一个目录中,因此最佳解决方案是创建另一个web.config并更改特定服务请求的executionTimeout。