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
WCF post文件限制_Wcf_Readerquotas - Fatal编程技术网

WCF post文件限制

WCF post文件限制,wcf,readerquotas,Wcf,Readerquotas,我在SharePoint中托管了WCF服务,该服务在不久前运行良好,但现在无法运行,我不明白为什么会发生这种情况。我尝试将文件发布到服务,如果文件小于16Kb没有错误,则得到错误400(badrequest)。我更改了我的配置文件,以便 <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IDocumen

我在SharePoint中托管了WCF服务,该服务在不久前运行良好,但现在无法运行,我不明白为什么会发生这种情况。我尝试将文件发布到服务,如果文件小于16Kb没有错误,则得到错误400(badrequest)。我更改了我的配置文件,以便

<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;
                    }
                }
            }
        }        
    }
公共类DocumentSetServiceFactory:MultipleBaseAddressBasicHttpBindingServiceHostFactory
{
受保护的重写ServiceHost CreateServiceHost(类型serviceType,Uri[]baseAddresses)
{
var sh=base.CreateServiceHost(serviceType,baseAddresses);
sh.开口+=sh_开口;
返回sh;
}
公共覆盖ServiceHostBase CreateServiceHost(字符串构造函数字符串,Uri[]基地址)
{
var sh=base.CreateServiceHost(构造函数字符串,baseAddresses);
sh.开口+=sh_开口;
返回sh;
}
无效SHU打开(对象发送器、事件参数e)
{
var sh=(ServiceHostBase)发送方;
LoggingService.LogDebug(“DocumentServiceHost:Open”);
如果(sh.Description!=null)
{
LoggingService.LogDebug(“DocumentServiceHost:说明不为空”);
foreach(sh.Description.Endpoints中的var端点)
{
LoggingService.LogDebug(string.Format(“DocumentServiceHost:FOR ENDPOINT{0}”,ENDPOINT.Address));
var bec=endPoint.Binding.CreateBindingElements();
var transport=bec.Find();
if(传输!=null)
{
LoggingService.LogDebug(string.Format(“DocumentServiceHost:TRANSPORT{0}”,TRANSPORT.Scheme));
transport.MaxReceivedMessageSize=5242880;
transport.MaxBufferPoolSize=5242880;
}
}
}
}        
}