我在SharePoint中托管的WCF服务在前一段时间内运行良好,但它现在不起作用,我不明白它为什么会发生。我尝试将文件发布到服务并获得错误400(badrequest)如果文件少16Kb没有错误。我改变了我的配置文件
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDocumentSetService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/_vti_bin/documentset.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDocumentSetService" contract="Sitronics.AFK.BoD.SharePoint.Services.Services.IDocumentSetService" name="BasicHttpBinding_IDocumentSetService" />
</client>
</system.serviceModel>
我需要在服务器端修改maxArrayLength,我该怎么办?服务主机按以下方式配置
public class DocumentSetServiceFactory : MultipleBaseAddressBasicHttpBindingServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
var sh = base.CreateServiceHost(serviceType, baseAddresses);
sh.Opening += sh_Opening;
return sh;
}
public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
{
var sh = base.CreateServiceHost(constructorString, baseAddresses);
sh.Opening += sh_Opening;
return sh;
}
void sh_Opening(object sender, EventArgs e)
{
var sh = (ServiceHostBase)sender;
LoggingService.LogDebug("DocumentServiceHost:Opening");
if (sh.Description != null)
{
LoggingService.LogDebug("DocumentServiceHost:Description is not null");
foreach (var endPoint in sh.Description.Endpoints)
{
LoggingService.LogDebug(string.Format("DocumentServiceHost:FOR ENDPOINT {0}", endPoint.Address));
var bec = endPoint.Binding.CreateBindingElements();
var transport = bec.Find<TransportBindingElement>();
if (transport != null)
{
LoggingService.LogDebug(string.Format("DocumentServiceHost:TRANSPORT {0}",transport.Scheme));
transport.MaxReceivedMessageSize = 5242880;
transport.MaxBufferPoolSize = 5242880;
}
}
}
}
}