当向WCF发送集合时,远程服务器返回一个错误:NotFound

本文关键字:一个 NotFound 错误 返回 服务器 WCF 集合 当向 | 更新日期: 2023-09-27 17:53:22

我正在尝试发送一个集合到WCF。当集合的大小不是很大(例如大小为10)时,它会正常发送。当大小增加到400-500时,我有一个错误说:"远程服务器返回了一个错误:NotFound"。

任何建议吗?

错误出现在这行之后:

wsClient。importFromExcelAsync(新System.Collections.ObjectModel.ObservableCollection (VIPcollection));

        private void buttonSendFile_Click(object sender, RoutedEventArgs e)
    {
        try
        {
            if (_fileName == null)
            {
                MessageBox.Show("...");
            }
            else
            {
                var streamFile = UploadTagetsFile(_fileName, _fileStream).ToString();
                var linesSplit = streamFile.ToString().Split('$');
                bool isHeader = (bool)checkBoxIsHeader.IsChecked;
                var splitFile = streamFile.Split('$');
                List<MgarIVR.VipCustomerService.VipCustomer> vipNewCollection = new List<VipCustomerService.VipCustomer>(); ;
                foreach (var vip in splitFile)
                {
                    if (isHeader)
                    {
                        isHeader = false;
                        continue;
                    }
                    var splitTarget = vip.Split(',');
                    try
                    {
                        if (IsDigitsOnly(splitTarget[1]) && IsDigitsOnly(splitTarget[2]))
                        {
                            var CustomerVip = new MgarIVR.VipCustomerService.VipCustomer();
                            CustomerVip.CustomerName = splitTarget[0];
                            CustomerVip.Phone1 = splitTarget[1];
                            CustomerVip.Phone2 = splitTarget[2];
                            CustomerVip.CustomerID = splitTarget[3];
                            CustomerVip.Skill = splitTarget[4];
                            CustomerVip.Priority = Int16.Parse(splitTarget[5]);
                            vipNewCollection.Add(CustomerVip);

                        }

                    }
                    catch (Exception ex)
                    {
                        LoggerService.LoggerServiceClient wslogClient = new LoggerService.LoggerServiceClient();
                        wslogClient.WriteToLogAsync(ex.Message);
                    }

                }
                VIPcollection = vipNewCollection;
                VipCustomerService.VipCustomerServiceClient wsClient = new VipCustomerService.VipCustomerServiceClient();                 
                wsClient.importFromExcelAsync(new System.Collections.ObjectModel.ObservableCollection<MgarIVR.VipCustomerService.VipCustomer>(VIPcollection));
                wsClient.importFromExcelCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(wsClient_importFromExcelCompleted);
            }

        }
        catch (Exception ex)
        {
            LoggerService.LoggerServiceClient wslogClient = new LoggerService.LoggerServiceClient();
            wslogClient.WriteToLogAsync(ex.Message);
        }
    }

ServiceReference。ClientConfig:

<configuration>
<system.serviceModel>
    <bindings>
      <binding>
        <readerQuotas maxArrayLength="2147483647"/>
      </binding>
      <basicHttpBinding>
            <binding name="BasicHttpBinding_ICDNservices" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
            <!--<binding name="BasicHttpBinding_IVipCustomerService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>-->
          <binding name="BasicHttpBinding_IVipCustomerService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
            <binding name="BasicHttpBinding_IVoiceMessageService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
            <binding name="BasicHttpBinding_ISpecialDaysService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
            <binding name="BasicHttpBinding_IWeekDaysService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
            <binding name="BasicHttpBinding_ILoggerService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
            <binding name="BasicHttpBinding_ISkillService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>

 <client>
  <endpoint address="http://localhost:54245/Services/SpecialDaysService.svc"
   binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISpecialDaysService"
   contract="SpecialDaysService.ISpecialDaysService" name="BasicHttpBinding_ISpecialDaysService" />
  <endpoint address="http://localhost:54245/Services/WeekDaysService.svc"
   binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWeekDaysService"
   contract="WeekDaysService.IWeekDaysService" name="BasicHttpBinding_IWeekDaysService" />
  <endpoint address="http://localhost:54245/Services/LoggerService.svc"
   binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILoggerService"
   contract="LoggerService.ILoggerService" name="BasicHttpBinding_ILoggerService" />
  <endpoint address="http://localhost:54245/Services/CDNservices.svc"
   binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICDNservices"
   contract="CDNservices.ICDNservices" name="BasicHttpBinding_ICDNservices" />
  <endpoint address="http://localhost:54245/Services/VoiceMessageService.svc"
   binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IVoiceMessageService"
   contract="VoiceMessageService.IVoiceMessageService" name="BasicHttpBinding_IVoiceMessageService" />
  <endpoint address="http://localhost:54245/Services/SkillService.svc"
   binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISkillService"
   contract="SkillService.ISkillService" name="BasicHttpBinding_ISkillService" />
  <endpoint address="http://localhost:54245/Services/VipCustomerService.svc"
   binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IVipCustomerService"
   contract="VipCustomerService.IVipCustomerService" name="BasicHttpBinding_IVipCustomerService" />
 </client>
</system.serviceModel>

网络。配置:

<configuration>

<!-- ================= Common(Misc) =================-->
<add key="logo" value="C:'Development'C#'Integration..."/>
<add key="CustomerLogoPath" value="C:'Development'C#'Integration..."/>
<add key="DownloadsFolderVirtualPath" value="ExcelDownload"/>
<add key="DownloadsFolderAbsolutePath" value="C:'Development'C#'Integration..."/>
<add key="NeedCheckAuthorize" value="false"/>
<add key="VoiceMessagePath" value="C:'Development'C#'Integration..."/>

<system.web>
    <compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

当向WCF发送集合时,远程服务器返回一个错误:NotFound

可以使用messageEncoding作为Mtom

                <binding messageEncoding="Mtom" ></binding> 

你可以增加缓冲区的大小

        <binding maxBufferSize="2000000" name="basicHttp"></binding>

你可能还想增加maxArrayLength

      <binding>
        <readerQuotas maxArrayLength="2147483647"/>
      </binding>

来源:https://social.msdn.microsoft.com/Forums/vstudio/en-US/f5c53569-3969-42ba-af26-40740f306c08/difference-between-maxarraylength-and-maxreceivedmessagesize?forum=wcf