获取WCF RIA服务超时
我正在运行大量WCF RIA服务操作,并在客户端Silverlight应用程序上遇到此类错误:获取WCF RIA服务超时,wcf,silverlight,silverlight-3.0,wcf-ria-services,wcf-configuration,Wcf,Silverlight,Silverlight 3.0,Wcf Ria Services,Wcf Configuration,我正在运行大量WCF RIA服务操作,并在客户端Silverlight应用程序上遇到此类错误: Uncaught Error: Unhandled Error occurred in Silverlight Application: Submit operation failed. Для запроса HTTP к "https://localhost/MyProject/ClientBin/myservice.svc/binary" has exceeded the allot
Uncaught Error: Unhandled Error occurred in Silverlight Application:
Submit operation failed. Для запроса HTTP к
"https://localhost/MyProject/ClientBin/myservice.svc/binary" has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.
Stack Trace:
в System.Windows.Ria.OperationBase.Complete(Exception error)
в System.Windows.Ria.SubmitOperation.Complete(Exception error)
в System.Windows.Ria.DomainContext.CompleteSubmitChanges(IAsyncResult asyncResult)
в System.Windows.Ria.DomainContext.<>c__DisplayClassd.<SubmitChanges>b__5(Object )
未捕获错误:Silverlight应用程序中发生未处理的错误:
提交操作失败。зззззззззззззз
"https://localhost/MyProject/ClientBin/myservice.svc/binary“已超过分配的超时时间。分配给此操作的时间可能是较长超时的一部分。
堆栈跟踪:
系统.Windows.Ria.OperationBase.Complete(异常错误)
of System.Windows.Ria.SubmitOperation.Complete(异常错误)
of System.Windows.Ria.DomainContext.CompleteSubmitChanges(IAsyncResult asyncResult)
of System.Windows.Ria.DomainContext.c__DisplayClassd.b__5(对象)
我在执行的1分钟内就得到了这样的超时
我的上下文是这样的:
[EnableClientAccess()]
public class ConfigService : LinqToEntitiesDomainService<MyEntityFrameworkEntities>
[EnableClientAccess()]
公共类ConfigService:LinqToEntitiesDomainService
以下是代码截图:
从客户端呼叫时,您希望增加sendTimeout属性 closeTimeout=连接关闭的时间间隔 openTimeout=连接打开的时间间隔 receiveTimeout=服务允许连接处于非活动状态的时间间隔
sendTimeout=客户端等待响应的时间间隔本主题中讨论的每个设置都是在绑定本身上进行的,无论是在代码还是配置中。下面的代码演示如何在自托管服务的上下文中以编程方式设置WCF绑定的超时
public static void Main()
{
Uri baseAddress = new Uri("http://localhost/MyServer/MyService");
try
{
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService));
WSHttpBinding binding = new WSHttpBinding();
binding.OpenTimeout = new TimeSpan(0, 10, 0);
binding.CloseTimeout = new TimeSpan(0, 10, 0);
binding.SendTimeout = new TimeSpan(0, 10, 0);
binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
serviceHost.AddServiceEndpoint("ICalculator", binding, baseAddress);
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
}
catch (CommunicationException ex)
{
// Handle exception ...
}
}
publicstaticvoidmain()
{
Uri baseAddress=新Uri(“http://localhost/MyServer/MyService");
尝试
{
ServiceHost ServiceHost=新的ServiceHost(typeof(CalculatorService));
WSHttpBinding=新的WSHttpBinding();
binding.OpenTimeout=newtimespan(0,10,0);
binding.CloseTimeout=新的时间跨度(0,10,0);
binding.SendTimeout=新的时间跨度(0,10,0);
binding.ReceiveTimeout=新的时间跨度(0,10,0);
AddServiceEndpoint(“ICalculator”,绑定,基址);
Open();
//现在可以访问该服务。
WriteLine(“服务准备就绪”);
控制台。WriteLine(“按以终止服务”);
Console.WriteLine();
Console.ReadLine();
}
捕获(通信例外)
{
//处理异常。。。
}
}
以下示例显示如何在配置文件中配置绑定超时
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding openTimeout="00:10:00"
closeTimeout="00:10:00"
sendTimeout="00:10:00"
receiveTimeout="00:10:00">
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
您应该使用edi进行RIA服务
域上下文创建后的任一行:
((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
((WebDomainClient)this.DomainClient.ChannelFactory.Endpoint.Binding.SendTimeout=new TimeSpan(0,5,0);
或者是一个偏类
public partial class LibraryDomainContext
{
partial void OnCreated()
{
if(DesignerProperties.GetIsInDesignMode(App.Current.RootVisual))
((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
}
}
公共部分类LibraryDomainContext
{
部分void OnCreated()
{
if(DesignerProperties.GetIsInDesignMode(App.Current.RootVisual))
((WebDomainClient)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout=new TimeSpan(0,5,0);
}
}
是的,我看到了,但它不起作用。可能是因为我在使用RIA服务。你知道怎么调整吗?不知道RIA。。。尝试此链接:实际上,错误更多地与RIA服务相关,而不是与WCF相关,这通常意味着我使用LinqToEntitiesDomainService扩展了我的自定义类如果我使用RIA Release versionpublic partial class LibraryDomainContext{partial void OnCreated(){if(DesignerProperties.GetIsInDesignMode),这可能是一个答案(App.Current.RootVisual))((WebDomainClient)this.DomainClient.ChannelFactory.Endpoint.Binding.SendTimeout=new TimeSpan(0,5,0);}}}}嘿,伙计!这会有用的!但是ChannelFactory是非公共的……你应该在代码中添加端点:factory.Endpoint.Binding.SendTimeout=new TimeSpan(0,10,0);我有两种方法的工厂:ReleaseDomainService和CreateDomainService。没有其他方法。让我试着向ChannelFactory投票。我不知道RIA Beta抱歉兄弟……如果你喜欢我的研究,请告诉我……你的wellcome兄弟。。。。