2009-07-07 60 views
4

我有一個WCF服務實現了回調協議,我試圖通過發送一個業務對象。我有裝飾有DataContract()和DataMember()中的業務對象屬性,並且它包含下列數量的屬性:通過WCF回調發送業務對象時發生超時

  • 整數:3
  • 字符串:4
  • 的XElement: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> 

回答

5

以下內容添加到你的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打開此文件。這應該會給你很多關於發生的事情的信息。

+0

這樣做會產生以下結果: 嘗試序列化參數http://tempuri.org/:submittedJob時發生錯誤。 InnerException消息是'類型'Utility.DAO.SubmittedJob',數據協定名稱爲'SubmittedJob:http://schemas.datacontract.org/2004/07/Utility.DAO'。將任何未知的靜態類型添加到已知類型列表中 - 例如,使用KnownTypeAttribute屬性或將它們添加到傳遞給DataContractSerializer的已知類型列表中。有關更多詳細信息,請參閱InnerException。 – 2009-07-07 15:26:34

+0

您可以使用KnownTypeAttribute(http://whiletrue.nl/blog/?p=36)來列出從您的基類派生的所有類。 – 2009-07-07 15:44:25

+0

我想我找到了問題...在web服務中,我已經將方法定義爲接受對象類型,並試圖發送一種提交作業。我改變了web服務來接受SubmittedJob,超時錯誤消失了。 – 2009-07-07 17:22:19

0

其他物體有多大?例如,XElement的子樹有多大?對象的圖形最終會變得非常大,特別是在調用其他對象時。

一個簡單的調查方法可能是刪除[DataMember]屬性,除了可能是其中一個字符串,並且一次重新引入它們一次,直到它斷開。

相關問題