【问题标题】:Timeout occuring when sending business object through WCF Callback通过 WCF 回调发送业务对象时发生超时
【发布时间】:2009-07-07 12:56:53
【问题描述】:

我有一个使用回调合同实现的 WCF 服务,我试图通过该合同发送业务对象。我有用 DataContract() 和 DataMember() 属性装饰的业务对象,它包含以下数量的属性:

  • 整数:3
  • 字符串:4
  • X 元素:1
  • 其他对象:5 个(也用 DataContract() 和 DataMember() 装饰

每当我尝试通过回调发送此对象时,服务都会超时。我已经尝试创建具有较少属性的其他对象以通过回调发送,并且如果只有一个属性可以让它通过,但如果我有多个属性,则服务超时。

我的配置有问题吗?我尝试了默认的 wsDualHttpBinding 以及 customBinding(如下所示),并且尝试了各种不同的设置,包括 maxBufferSize、maxBufferPoolSize 和 maxReceivedMessageSize。我不想增加超时,因为我希望这个对象能很快到达我的客户。请有人帮我...如果我还有头发,我现在早就把它拔掉了!!!!!

我已经这样配置了我的服务:

服务器配置:

    <customBinding>
        <binding name="DualBindingConfig">
            <reliableSession flowControlEnabled="true" maxPendingChannels="128" />
            <compositeDuplex />
            <oneWay/>
            <binaryMessageEncoding/>
            <httpTransport maxReceivedMessageSize="655360000" maxBufferPoolSize="655360000" />
        </binding>
    </customBinding>
    <services>
        <service behaviorConfiguration="Agent_Utility_WCF.Callback.AgentMessagingBehavior"
            name="Agent_Utility_WCF.Callback.AgentMessaging">
            <endpoint address="" binding="customBinding" bindingConfiguration="DualBindingConfig" bindingName="AgentMessaging" contract="Agent_Utility_WCF.Callback.IAgentMessaging">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="Agent_Utility_WCF.Callback.AgentMessagingBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceThrottling maxConcurrentCalls="160" maxConcurrentSessions="100"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>

客户端配置:

<bindings>
    <customBinding>
        <binding name="AgentMessaging_IAgentMessaging">
            <reliableSession acknowledgementInterval="00:00:00.2000000" flowControlEnabled="true"
                inactivityTimeout="00:10:00" maxPendingChannels="4" maxRetryCount="8"
                maxTransferWindowSize="8" ordered="true" reliableMessagingVersion="Default" />
            <compositeDuplex />
            <oneWay maxAcceptedChannels="10" packetRoutable="false">
                <channelPoolSettings idleTimeout="00:02:00" leaseTimeout="00:10:00"
                    maxOutboundChannelsPerEndpoint="10" />
            </oneWay>
            <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                maxSessionSize="2048">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            </binaryMessageEncoding>
            <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                useDefaultWebProxy="true" />
        </binding>
    </customBinding>
</bindings>
<client>
    <endpoint address="http://localhost:666/Callback/AgentMessaging.svc"
        binding="customBinding" bindingConfiguration="AgentMessaging_IAgentMessaging"
        contract="AgentMessaging.IAgentMessaging" name="AgentMessaging_IAgentMessaging">
        <identity>
            <dns value="localhost" />
        </identity>
    </endpoint>
</client>

【问题讨论】:

    标签: c# .net wcf callback


    【解决方案1】:

    将以下内容添加到您的 web.config:

    <system.diagnostics>
        <trace autoflush="true">
            <listeners>
            </listeners>
        </trace>
        <sources>
            <source name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
                <listeners>
                    <add name="sdt"
                         type="System.Diagnostics.XmlWriterTraceListener"
                         initializeData= "WcfDetailTrace.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>
    

    然后调用您的 Web 服务方法。这将在您网站的根目录中生成 WcfDetailTrace.svclog。使用SvcTraceViewer.exe 打开此文件。这应该可以为您提供有关正在发生的事情的大量信息。

    【讨论】:

    • 这样做会产生以下结果:尝试序列化参数tempuri.org/:submittedJob 时出错。 InnerException 消息是 'Type 'Utility.DAO.SubmittedJob',数据合同名称为 'SubmittedJob:schemas.datacontract.org/2004/07/Utility.DAO' 不是预期的。将任何静态未知的类型添加到已知类型列表中 - 例如,通过使用 KnownTypeAttribute 属性或将它们添加到传递给 DataContractSerializer 的已知类型列表中。有关详细信息,请参阅 InnerException。
    • 您可以使用 KnownTypeAttribute (whiletrue.nl/blog/?p=36) 来列出从您的基类派生的所有类。
    • 我想我发现了问题...在 web 服务中,我已将方法定义为接受对象类型,并尝试发送 SubmittedJob 类型。我将 web 服务更改为接受 SubmittedJob,超时错误消失了。
    【解决方案2】:

    其他物体有多大?例如,XElement 的子树有多大?一个对象的图最终会变得非常大,尤其是当它调用其他对象时。

    一种简单的调查方法可能是删除 [DataMember] 属性(可能是其中一个字符串除外),然后一次重新引入一个,直到它中断。

    【讨论】:

    • 考虑到这个目标,我创建了另一个只有一个属性的测试对象,并通过我的网络服务成功提交了它。之后我添加了另一个属性,它不再通过...
    【解决方案3】:

    【讨论】:

    • 感谢您的回答,但我暂时放弃了 silverlight 项目。
    • 我几乎也不得不放弃一个,直到我找到这个......也许下一次!
    猜你喜欢
    • 2012-08-19
    • 1970-01-01
    • 2011-02-13
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    • 2011-09-01
    • 2012-10-22
    相关资源
    最近更新 更多