【发布时间】:2014-05-14 14:26:31
【问题描述】:
我的 wcf 服务有问题。 我已阅读有关此错误的所有帖子,我尝试了几乎所有的道具,但它不起作用! 我想上传小于 1 mb 的图片。
我的客户端通过代码配置: EndpointAddress ea = new EndpointAddress("AddressofServer"); BasicHttpBinding basicHttpBinding = new BasicHttpBinding(); XmlDictionaryReaderQuotas reader = new XmlDictionaryReaderQuotas(); basicHttpBinding.MaxBufferSize = 2147483647; basicHttpBinding.MaxBufferPoolSize = 2147483647; basicHttpBinding.MaxReceivedMessageSize = 2147483647; reader.MaxStringContentLength = 2147483647; reader.MaxDepth = 2147483647; reader.MaxArrayLength = 2147483647; reader.MaxBytesPerRead = 2147483647; reader.MaxNameTableCharCount = 2147483647; basicHttpBinding.ReaderQuotas = 读者;
basicHttpBinding.SendTimeout = new TimeSpan(0, 0, 50);
basicHttpBinding.OpenTimeout = new TimeSpan(0, 0, 5);
basicHttpBinding.ReceiveTimeout = basicHttpBinding.SendTimeout;
basicHttpBinding.AllowCookies = false;
basicHttpBinding.Security.Mode = BasicHttpSecurityMode.None;
ServiceReference1.Service1Client sc = new ServiceReference1.Service1Client(basicHttpBinding, ea);
string nm = sc.Endpoint.Binding.Name;
using (FileStream fs = new FileStream("c:\\httpfiles\\test.jpg", FileMode.Open))
{
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
sc.GetImage(1, "appareillage", buffer);
}
我的 web.config 文件:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="bnd"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" messageEncoding="Text">
<readerQuotas
maxArrayLength="2147483647"
maxStringContentLength="2147483647" />
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment
multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
<services>
<service name="PodoTouchService.PTouchService" behaviorConfiguration="" >
<endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="bnd"
contract="Service1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true">
<requestLimits maxAllowedContentLength="2147483647"/>
<fileExtensions allowUnlisted="true"/>
<verbs allowUnlisted="true"/>
</requestFiltering>
</security>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
我也尝试更改 applicationHost.config。
有什么想法吗?
【问题讨论】:
-
错误是什么?复制并粘贴异常。