Silverlight 中的 WCF - 如何设置更改 1 分钟的默认超时 [英] WCF in Silverlight - how to set change the default timeout of 1 minute

查看:34
本文介绍了Silverlight 中的 WCF - 如何设置更改 1 分钟的默认超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Silverlight 项目中连接了一个 WCF 服务.服务需要执行的任务需要一分钟(这很好),但我收到错误消息.我通过代理与它通信(在添加服务引用时由 dev studio 创建)

<块引用>

对http://localhost/ImporterService.svc"的 HTTP 请求已超过分配的超时时间.分配给此操作的时间可能是较长超时的一部分.

(其中 ImporterService 是我的服务)

在过去 3 天里,我阅读了各种关于增加以下内容的帖子.

receiveTimeout="00:10:00"sendTimeout="00:10:00"openTimeout="00:10:00"closeTimeout="00:10:00"

没有任何效果,1分钟后仍然超时!

好的,所以在生成的 ServiceReferences.ClientConfig 文件中,我在以下位置添加了值

<预><代码><配置><system.serviceModel><绑定><基本HttpBinding><绑定名称="BasicHttpBinding_ImporterService" maxBufferSize="2147483647"接收超时=00:10:00"sendTimeout="00:10:00"openTimeout="00:10:00"closeTimeout="00:10:00"maxReceivedMessageSize="2147483647"><安全模式=无"/></binding>....

此超时似乎发生在客户端(例如,我可以通过在服务代码中添加 1 分钟睡眠来实现)

问题 1所以,就我而言,我只需要更改客户端.

无论如何在 web.config 中在 web.config 中,我添加了块

在现有的中如下所示><基本HttpBinding>><binding name="downloadBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000">><readerQuotas maxArrayLength="2000000" maxStringContentLength="2000000"/>></binding>>><绑定名称="BasicHttpBinding_IImporterService" maxBufferSize="2147483647">receiveTimeout="00:10:00">sendTimeout="00:10:00">openTimeout="00:10:00">closeTimeout="00:10:00">maxReceivedMessageSize="2147483647">><security mode="None"/>></binding>>></basicHttpBinding>></绑定>

注意我使用的名称是 BasicHttpBinding_IImporterService(其他帖子使用了随机名称,它们在客户端和服务器上甚至不一样!例如

我也将 <httpRuntime executionTimeout 设置为一个巨大的值.

超时不会增加.还有 1 分钟.

那么,大问题

<代码>1.我做错了什么,我是否将这些设置放在错误的地方?2.我需要做的只是客户端吗3.如果这些配置设置不起作用,也许可以在代码中完成

例如在我使用它的地方,我使用实例化

<块引用>

ImporterServiceClient importerService = new ImporterServiceClient("*", new >EndpointAddress(ServicePath));

我知道还有很多其他帖子,但是,但大多数只包含属性,而不是确切地设置它们的位置,所以显然我的位置错误?

任何帮助将不胜感激.我想要做的就是增加超时时间(在代码、配置、任何实际可行的地方)!

在此先感谢任何可以提供帮助的人皮特

解决方案

在 web.config 中无需添加任何超时数据.将超时设置添加到您的 SL 应用程序.当您将 ServiceRefferences 添加到您的项目中时,VisualStudio 必须生成文件

ServiceReferences.ClientConfig

我有这个配置

<安全模式=无"/></binding></basicHttpBinding></绑定><客户><端点地址="http://mySite/MyService.svc"binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEventsService"contract="EventService.IEventsService" name="BasicHttpBinding_IEventsService"/></客户端></system.serviceModel>

您可以根据需要设置超时参数.希望这会有所帮助.

I have a WCF service I am connecting to in in a Silverlight project. The task the service needs to do takes over a minute (which is fine), but I get an error. I communicate to it via a proxy (created by dev studio when you add a service reference)

The HTTP request to 'http://localhost/ImporterService.svc' has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.

(where ImporterService is my service)

I Have read all sort of posts for the last 3 days about increasing the following.

receiveTimeout="00:10:00"
sendTimeout="00:10:00"
openTimeout="00:10:00"
closeTimeout="00:10:00"

Nothing has worked, it still times out after 1 minute!

Ok, so in the file ServiceReferences.ClientConfig generated I have added the values in the following place

<configuration>
  <system.serviceModel>
  <bindings>
   <basicHttpBinding>
   <binding name="BasicHttpBinding_ImporterService" maxBufferSize="2147483647"
      receiveTimeout="00:10:00"
      sendTimeout="00:10:00"
        openTimeout="00:10:00"
        closeTimeout="00:10:00"
        maxReceivedMessageSize="2147483647">
        <security mode="None" />
        </binding>
        ....

This timeout appear to be occurring on the client side (eg I can make it happen by adding a 1 minutes sleep in the service code)

Question1 So, in my case is it only the client side I need to change.

At any rate in the web.config In the web.config, I added the block

inside the existing <basicHttpBinding> as shown below


 ><basicHttpBinding>
    ><binding name="downloadBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000">
    ><readerQuotas maxArrayLength="2000000" maxStringContentLength="2000000" />
    ></binding>
    >    
    ><binding name="BasicHttpBinding_IImporterService" maxBufferSize="2147483647"
    >receiveTimeout="00:10:00"
    >sendTimeout="00:10:00"
    >openTimeout="00:10:00"
    >closeTimeout="00:10:00"
    >maxReceivedMessageSize="2147483647">
    ><security mode="None" />
    ></binding>
    >    
    ></basicHttpBinding>            
    ></bindings>

Note I am using the names BasicHttpBinding_IImporterService (other posts have used random names where they are not even the same on the client and server! e.g.

I also have <httpRuntime executionTimeout set to a huge value.

The time out just does not increase. It is still 1 minute.

So, big questions

1. What an I doing wrong, am I putting these settings in the wrong place?
2. Is it just client side I need to do
3. Perhap it can be done in code if these config settings don't work

Eg where I use it, I instantiated using

ImporterServiceClient importerService = new ImporterServiceClient("*", new >EndpointAddress(ServicePath));

I know there are lots other other post, but, but most just include the properties, and not exactly where to set them, so obviously mine are in the wrong place?

Any help would be greatly appreciated. All I want to do is increase a time out (in code, config, anywhere that will actually work)!

Thanks in advance to any one that can help here Pete

解决方案

In web.config no need add any timeout data. add timeout settings to your SL app. When you add ServiceRefferences into you project VisualStudio must generate file

ServiceReferences.ClientConfig

I have this config

<?xml version="1.0" encoding="utf-8"?>

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>

            <binding name="BasicHttpBinding_IEventsService" closeTimeout="01:59:00"
                receiveTimeout="01:59:00" sendTimeout="01:59:00" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://mySite/MyService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEventsService"
            contract="EventService.IEventsService" name="BasicHttpBinding_IEventsService" />

    </client>
</system.serviceModel>

You can set timeout params as you need. Hope this help.

这篇关于Silverlight 中的 WCF - 如何设置更改 1 分钟的默认超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆