SharePoint 2013 自定义WCF上传文档报错
霖雨 版主
博客专家认证 2014-03-11 09:56:28 环境:Windows Server 2012 + SharePoint 2013 + Visual Studio 2012
代码:SharePoint解决方案自定义WCF服务
功能:提权上传文档到文档库
报错:
未经处理的异常: System.ServiceModel.ProtocolException: 远程服务器返回了意外响应
: (413) Request Entity Too Large。 ---> System.Net.WebException: 远程服务器返回
错误: (413) Request Entity Too Large。
在 System.Net.HttpWebRequest.GetResponse()
在 System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpC
hannelRequest.WaitForReply(TimeSpan timeout)
--- 内部异常堆栈跟踪的结尾 ---
说明:
我写的WCF服务,有两个方法,一个是测试用的获取站点Title,没有问题;另一个是上传文档到文档库,文档很小的时候(大约几KB)没有问题,文件过大(10MB左右)报错,响应实体太大;
我昨天查了一天资料,有说需要配置IIS的MetaBase.xml里面<IIsWebService节点下的AspMaxRequestEntityAllowed="204800",但是windows server 2012的MetaBase.xml里面默认没有这个节点,手动添加不好使!
还有说配置SVC的web.config,然后endpoint报错
已将绑定实例关联到侦听 URI“http://spappdev/_vti_bin/UploadApp/UploadService.svc”。如果两个终结点要共享相同的 ListenUri,则它们必须也共享相同的绑定对象实例。可以在 AddServiceEndpoint() 调用、配置文件或 AddServiceEndpoint() 和配置文件的组合中指定两个冲突的终结点。
附配置文件
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" maxBufferPoolSize="5242880000" maxBufferSize="655360000"
maxReceivedMessageSize="655360000" />
</basicHttpBinding>
</bindings>
<services>
<service name="sp.UploadService">
<host>
<baseAddresses>
<add baseAddress="http://myserver/_vti_bin/UploadApp/UploadService.svc" />
</baseAddresses>
</host>
<endpoint address="" bindingConfiguration="NewBinding0" binding="basicHttpBinding" contract="sp.IUploadService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
总而言之,言而总之,改IIS配置文件没起作用,也可能自己没改对;IIS里面的配置,没找到有好用的;改WCF的配置,没改通。。太纠结了。。希望大家帮我想想办法~~谢谢了~~