我正在尝试向WCF发送一个集合。当集合的大小不是那么大(例如10的大小)时,它正常发送。当大小增加到400-500时,我有一个错误:"远程服务器返回错误:NotFound"。
有什么建议吗?
此行后出现错误:
wsClient.importFromExcelAsync(new 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>
Web.Config中:
<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>
答案 0 :(得分:0)
您可以将messageEncoding用作Mtom。
<binding messageEncoding="Mtom" ></binding>
您可以增加缓冲区大小
<binding maxBufferSize="2000000" name="basicHttp"></binding>
您可能还想增加maxArrayLength
<binding>
<readerQuotas maxArrayLength="2147483647"/>
</binding>