2012-07-08 73 views
1

我的WCF客戶端在WCF服務器上工作正常,除了在嘗試傳遞自定義對象數組時調用服務器。當數組是100個項目時,它可以正常工作,但是當項目數量爲300時,服務器會拋出異常錯誤請求(400)。所以我認爲解決方案的關鍵在於配置文件。WCF:服務器響應錯誤請求(400)

首先這裏是客戶端的app.config。 WCF客戶端駐留在一個名爲Outlook Add-In的DLL中。我複製此的app.config到Outlook.exe.config到Outlook安裝目錄 - 這是必需的加載項由Outlook加載的東西:

<configuration> 
    <configSections> 
     <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > 
      <section name="MyProject.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> 
     </sectionGroup> 
    </configSections> 
    <system.serviceModel> 
     <bindings> 
      <wsDualHttpBinding> 
       <binding name="WSDualHttpBinding_IJabberSvc" closeTimeout="00:01:00"   openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" 
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"> 
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
         maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
        <reliableSession ordered="true" inactivityTimeout="00:10:00" /> 
        <security mode="Message"> 
         <message clientCredentialType="Windows" negotiateServiceCredential="true" 
          algorithmSuite="Default" /> 
        </security> 
       </binding> 
      </wsDualHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost:9047/switchvox/alerter" binding="wsDualHttpBinding" 
       bindingConfiguration="WSDualHttpBinding_IJabberSvc" contract="JabberService.IJabberSvc" 
       name="WSDualHttpBinding_IJabberSvc"> 
      </endpoint> 
     </client> 
    </system.serviceModel> 
    <system.diagnostics> 
    <trace autoflush="true" /> 
    <sharedListeners> 
     <add name="sharedListener" 
     type="System.Diagnostics.XmlWriterTraceListener" initializeData="%AppData%\Mfg\ProjectName\Logs\SwitchvoxDialerTraceLog.svclog" /> 
    </sharedListeners> 
    <sources> 
     <source name="System.ServiceModel" 
       switchValue="Verbose, ActivityTracing" 
       propagateActivity="true"> 
     <listeners> 
      <add name="sharedListener"/> 
     </listeners> 
     </source> 
     <source name="System.ServiceModel.MessageLogging" switchValue="Verbose"> 
     <listeners> 
      <add name="sharedListener" /> 
     </listeners> 
     </source> 
    </sources> 
    </system.diagnostics> 

    <userSettings> 
    <SwitchvoxDialer.Properties.Settings> 
     <setting name="InstallSubFolder" serializeAs="String"> 
     <value>Mfg\\ProjectName</value> 
     </setting> 
     <setting name="DialerTitle" serializeAs="String"> 
     <value>ProjectName</value> 
     </setting> 
    </SwitchvoxDialer.Properties.Settings> 
    </userSettings> 
</configuration> 

服務器配置的相關部分看起來是這樣的:

<system.serviceModel> 
    <services> 
     <service name="WcfServiceLib.JabberSvc" behaviorConfiguration="JabberSvc"> 
     <endpoint address="http://localhost:9047/switchvox/alerter"  binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IJabberSvc" contract="WcfServiceLib.IJabberSvc" name="WSDualHttpBinding_IJabberSvc"> 
      <identity> 

     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:9047/switchvox/alerter"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="JabberSvc"> 
      <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483646" /> 
      <serviceTimeouts transactionTimeout="00:10:00" /> 
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="True"/> 
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true. Set to false before deployment 
      to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsDualHttpBinding> 
     <binding name="WSDualHttpBinding_IJabberSvc" closeTimeout="00:01:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" 
       bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="2147483647" 
         maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" 
         maxBytesPerRead="2147483647" 
         maxNameTableCharCount="2147483647"/> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00"/> 
      <security mode="Message"> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/> 
      </security> 
     </binding> 
     </wsDualHttpBinding> 
    </bindings> 
    <!-- Enable message tracing by adding this section - Remove for production code --> 
    <diagnostics> 
     <messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="true" 
     maxMessagesToLog="100000" /> 
    </diagnostics> 

    </system.serviceModel> 

在app.config產生ServerName.exe.config在斌/調試(以前我曾作爲嵌入的資源,但它並沒有幫助...

正如你可以看到我都增加了緩衝區,消息等的數量最大並確保時間值足夠高......我確信問題是服務器或客戶端不知道這些增加的值,但不知道爲什麼......

+0

您是主辦該服務還是第三方? – Bronumski 2012-07-09 01:05:13

+0

它是我自己的自託管服務,也就是我寫的,它不是由IIS託管的。 – 2012-07-09 16:10:31

回答

1

嘗試使用MTOM進行消息編碼。請參閱以下鏈接,瞭解更多信息:

http://msdn.microsoft.com/en-us/library/ms733742.aspxhttp://msdn.microsoft.com/en-us/library/aa395209.aspx

如果不起作用,使用Fiddler獲得有關錯誤的詳細信息。 400錯誤的請求可能意味着很多事情。

+0

它可以使用DualHttpBinding嗎?它只引用這些文章中的BasicHttpBinding ... – 2012-07-09 00:02:45

+0

Fiddler是一個非常有用的程序,謝謝...但是我仍然無法找到問題所在 - Fiddler在引發時不顯示任何異常。然後由於這個例外,客戶端/服務器通道在10-20秒後關閉,並且我捕獲客戶端在封閉通道上與服務器交談的任何額外嘗試(我能看到的只有少數HTTP 503代碼(服務不可用),但我認爲它只是反映了異常後會發生什麼... – 2012-07-09 01:02:46

1

WCF不會返回/顯示大量有關其側面的實際錯誤(悲傷)的信息。嘗試配置WCF Tracing並查看是否有幫助。

+0

這是我看到的第一件事 - 它顯示相同的錯誤請求,沒有別的...... – 2012-07-09 04:05:22

+0

您是否嘗試將調試會話附加到IIS並逐步執行代碼? – muruge 2012-07-09 06:08:50

+0

沒有IIS,它是自我託管的,是的,我調試它,並得到這個異常,客戶端調用服務器API試圖傳輸500個項目時,當我嘗試100個項目,然後它工作正常。 – 2012-07-09 16:12:11

相關問題