Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays WCF:服务器响应错误请求(400)_Arrays_Wcf_Exception_App Config_Mtom - Fatal编程技术网

Arrays WCF:服务器响应错误请求(400)

Arrays WCF:服务器响应错误请求(400),arrays,wcf,exception,app-config,mtom,Arrays,Wcf,Exception,App Config,Mtom,我的WCF客户端可以与WCF服务器一起工作,除非调用服务器试图传递自定义对象数组。当数组为100个项目时,它工作正常,但当项目数为300时,服务器抛出异常错误请求(400)。因此,我假设解决方案的关键在配置文件中 首先,这里是客户端的app.config。WCF客户端驻留在一个DLL中,该DLL是Outlook加载项。我将此app.config复制到Outlook.exe.config到Outlook安装目录-Outlook加载外接程序所需的内容: <configuration>

我的WCF客户端可以与WCF服务器一起工作,除非调用服务器试图传递自定义对象数组。当数组为100个项目时,它工作正常,但当项目数为300时,服务器抛出异常错误请求(400)。因此,我假设解决方案的关键在配置文件中

首先,这里是客户端的app.config。WCF客户端驻留在一个DLL中,该DLL是Outlook加载项。我将此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在bin/Debug中生成ServerName.exe.config(以前我将其作为嵌入式资源使用,但也没有帮助)


正如您所见,我将缓冲区、消息等的所有数字都增加到了最大值,并确保时间值足够高……我确信问题在于服务器或客户端不知何故不知道这些增加的值,但无法找出原因……

尝试使用MTOM进行消息编码。请参阅以下内容有关更多信息的链接:

如果这不起作用,请使用Fiddler获取有关错误的更多信息。
一个400个错误的请求可能意味着很多事情。

WCF不会返回/显示大量关于其内部实际错误的信息(sad)。请尝试配置,看看是否有帮助。

是否可以与DualHttpBinding一起使用?在这些文章中,它仅引用BasicHttpBinding…Fiddler是一个非常有用的程序,谢谢…但我仍然找不到问题所在-Fiddler在抛出时未显示任何异常。然后,由于此异常,客户端/服务器通道关闭10-20秒conds之后,我捕捉到客户端在封闭通道上与服务器对话的任何其他尝试(我所能看到的只是少量HTTP 503代码(服务不可用)但我认为它只是反映了异常发生后发生的情况…你是托管该服务还是第三方?这是我自己的自托管服务,也就是说,我编写了它,但它不是由IIS托管的。这是我看到的第一件事-它显示了相同的错误请求,没有其他内容…你是否尝试将调试会话附加到IIS并单步执行代码是什么?没有IIS。它是自托管的。是的,我调试了它,并且在客户端调用服务器API尝试传输500个项目时出现了此异常。当我尝试100个项目时,它工作正常。@LeonHavin:如果您能够调试它,那么抛出的异常类型是什么?stacktrace将您指向哪里?抛出的异常异常为:CommunicationException:远程服务器返回意外响应:(400)错误请求。