-1
我目前正在研究上傳和下載文件到WCF服務的解決方案。客戶端是從ClientBase繼承的類。我讀過關於StackOverflow和其他地方的流媒體和鏈接的MSDN article,但我似乎無法弄清楚爲什麼我仍然收到有關郵件大小太小的消息。我已經用小文件測試瞭解決方案,並且它工作正常。從ClientBase上傳文件到WCF服務<T>
該服務託管在IIS 7.5
這裏從客戶機應用程序在app.config
<system.web>
<httpRuntime maxRequestLength="67108864" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding messageEncoding="Mtom" transferMode="Streamed" name="LargeFileStreamingHttpBinding"
maxBufferSize="65536"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/UpdateService.svc"
binding="basicHttpBinding"
contract="IUpdateService"
name="updateServiceEndpoint"/>
</client>
</system.serviceModel>
下面是在服務器中的相關章節
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="UpdateService" behaviorConfiguration="UpdateServiceBehavior">
<endpoint binding="basicHttpBinding" bindingName="LargeFileStreamingWebHttpBinding" contract="IUpdateService"></endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="UpdateServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding messageEncoding="Mtom" transferMode="Streamed" name="LargeFileStreamingWebHttpBinding"
maxBufferSize="65536"
maxReceivedMessageSize="2147483647"
/>
</basicHttpBinding>
</bindings>
</system.serviceModel>
此外,我在服務器和客戶端配置中添加了以下內容:
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
這是我如何實例化客戶端
public class UpdateClient : ClientBase<IUpdateService>, IUpdateService
{
public UpdateClient() : base("updateServiceEndpoint") {}
}
所以不會有任何想法,我可以去錯了嗎?任何幫助表示讚賞。
- 謝謝!
是服務類的名稱只是「UpdateService」,或者它的一些命名空間屬於?如果是後者,則需要在<'上具有完全限定的名稱,以便獲取配置。 –
carlosfigueira
爲了簡潔起見,我省略了服務合約名稱空間 – abjbhat
由於本地化過於封閉,因爲沒有其他人會犯這個特別的錯誤,因此無法通過搜索這個問題找到答案。 –