首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取WCF RIA服务超时

获取WCF RIA服务超时
EN

Stack Overflow用户
提问于 2013-05-17 15:49:19
回答 2查看 1.9K关注 0票数 1

我正在运行繁重的WCF RIA服务操作,并且在客户端Silverlight应用程序上遇到这样的错误:

代码语言:javascript
复制
    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 )

我在执行的1分钟内就得到了这样的超时。

我的上下文是这样的:

代码语言:javascript
复制
[EnableClientAccess()]
public class ConfigService : LinqToEntitiesDomainService<MyEntityFrameworkEntities>

下面是代码截图:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-05-17 17:08:25

本主题中讨论的每个设置都是在绑定本身上进行的,可以在代码中进行,也可以在配置中进行。下面的代码演示如何在自承载服务的上下文中以编程方式设置WCF绑定的超时。

代码语言:javascript
复制
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 ...
                }
            }

下面的示例显示如何在配置文件中配置绑定的超时。

代码语言:javascript
复制
<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>

您应该为RIA服务使用edi

在域上下文创建后执行操作:

代码语言:javascript
复制
((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);

或者是分部类

代码语言:javascript
复制
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);
   }
}
票数 2
EN

Stack Overflow用户

发布于 2013-05-17 16:23:13

当从客户端调用时,您希望增加sendTimeout属性。

closeTimeout =连接关闭的时间间隔

openTimeout =打开连接的时间间隔

receiveTimeout =服务允许连接处于非活动状态的时间间隔

sendTimeout =客户端等待响应的时间间隔

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16604053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档